Skip to content

FileManager.renameFile method

FileManager › renameFile

Official

Rename or move a file or folder safely, and update all links to it depending on the user's preferences.

Signature:

renameFile(file: TAbstractFile, newPath: string): Promise<void>

Parameters:

ParameterTypeDescription
fileTAbstractFilethe file or folder.
newPathstringthe new path.

Returns: Promise<void>

Since: 0.11.0

Example:

const file = vault.getFileByPath('foo/bar.md');
await fileManager.renameFile(file, 'baz/qux.md');