moveFolder()v4.0.528
Moves a folder and its contents into another folder, to the root, or beside another registration.
Draft API: This API is experimental and may change.
move-folder.tsimport {moveFolder , typeCodemodProject } from '@remotion/codemods'; declare constproject :CodemodProject ; constresult =moveFolder ({project ,compositionFile : 'src/Root.tsx',folder : {name : 'Published',parentName : 'Social'},destination : {type : 'root'}, });console .log (result );
Moving a folder into itself or a descendant is rejected. A folder with the same name at the destination is also rejected. Update descendant parentName paths after the move.
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 static IDs or folder names. Aliased and namespace imports from remotion are supported.
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.
destination
Where to move the item. Use {type: 'root'}, {type: 'folder', folder: {name, parentName}}, or {type: 'before' | 'after', target}. A target is {type: 'composition', compositionId} or {type: 'folder', name, parentName}. Moving an item into its current parent is a no-op.
destinationFile?v4.0.542
The project file containing the destination. Defaults to null: named destinations are resolved in compositionFile first, then across project.files if absent. The destination must be unambiguous. For {type: 'root'}, null means the root of compositionFile.
When moving between files, include both files in project.files. Imported components and props are transferred, relative import paths are updated, and conflicting import names are aliased. Imports still used in the source file are retained. Apply all returned changes together.
Registrations that reference variables declared outside the moved JSX cannot move between files. Move these dependencies into an imported module first. Unsupported moves throw before returning any changes.
Return value
Returns an object with the following properties.
changes
An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.
nodePathRemappingsv4.0.530
An array of {filePath, oldNodePath, newNodePath} mappings. A null old path indicates an insertion; a null new path indicates removal. Apply these mappings to references from the input project. See node references.
updatedNodev4.0.530
The moved <Folder> element's node reference in the new project. For cross-file moves, use this reference to locate the folder in its destination 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 | ||||