要件によって2パターンある。 ## 変更時にリンクも修正したい場合 [[ノート]]をリネームしたとき、その[[ノート]]への[[リンク]]にも変更が必要な場合は `renameFile` を使う。 ```ts export class FileManager { /** * Rename or move a file safely, and update all links to it depending on the user's preferences. * @param file - the file to rename * @param newPath - the new path for the file * @public */ renameFile(file: TAbstractFile, newPath: string): Promise<void>; ``` ```ts await app.fileManager.renameFile( activeFile, "hogedir/hoge.md" ); ``` ## 変更時にリンクは修正したくない場合 [[ノート]]をリネームしたとき、その[[ノート]]への[[リンク]]は**変更したくない**場合は `rename` を使う。 ```ts export interface DataAdapter { /** * Rename a file or folder. * @param normalizedPath - current path to file/folder, use {@link normalizePath} to normalize beforehand. * @param normalizedNewPath - new path to file/folder, use {@link normalizePath} to normalize beforehand. * @public */ rename(normalizedPath: string, normalizedNewPath: string): Promise<void>; ``` ```ts await app.vault.adapter.rename( "_Privates/emojis.md", "_Privates/emojis2.md" ) ```