Skip to content

Vault.getAbstractFileByPath method

Vault › getAbstractFileByPath

Official

Get a file or folder inside the vault at the given path. To check if the return type is a file, use instanceof TFile. To check if it is a folder, use instanceof TFolder.

Signature:

getAbstractFileByPath(path: string): TAbstractFile | null

Parameters:

ParameterTypeDescription
pathstringvault absolute path to the folder or file, with extension, case sensitive.

Returns: TAbstractFile | null — The file or folder, or null if it's not found.

Since: 0.11.11

Example:

console.log(vault.getAbstractFileByPath('existent-file.md')); // TFile
console.log(vault.getAbstractFileByPath('existent-folder')); // TFolder
console.log(vault.getAbstractFileByPath('non-existent-file.md')); // null
console.log(vault.getAbstractFileByPath('non-existent-folder')); // null