renameFolder()v4.0.528
Renames a folder while keeping its contents.
Draft API: This API is experimental and may change.
rename-folder.tsimport {renameFolder , typeCodemodProject } from '@remotion/codemods'; declare constproject :CodemodProject ; constresult =renameFolder ({project ,compositionFile : 'src/Root.tsx',folder : {name : 'Social',parentName : null},newName : 'Published', });console .log (result );
After renaming a folder, update the parentName paths used to address its descendants. Renaming to the current name is a no-op.
Options
project
An in-memory CodemodProject. The input project is not mutated.
compositionFile
The project file containing the composition registrations. Registration edits support <Composition>, <Still>, and <Folder> with their original import names and static IDs or folder names.
folder
Identifies a folder in compositionFile.
name
The folder name.
parentName
The slash-separated path of the parent folder, such as Social/Published. Use null for a top-level folder.
newName
The new non-empty name, without /. It must be unused in the parent folder.
Return value
Returns an object with the following properties.
project
The updated project. Unchanged files and extra project fields are preserved.
changes
An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.
Errors
Throws when the target cannot be resolved, the requested edit is unsupported, or an option is invalid. Failed edits leave the input project unchanged.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||