Skip to content

TFile

Official

A file.

Import:

import { TFile } from 'obsidian';

Signature:

export class TFile extends TAbstractFile

Extends: TAbstractFile

Constructor

new TFile(vault: Vault, path: string)

Constructor.

To get the constructor instance, use getTFileConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
basenamestringThe basename of the file (name without extension).
deletedbooleanWhether the file or folder is being deleted.
(Inherited from TAbstractFile)
extensionstringThe extension of the file.
namestringThe name of the file (with extension).
parentnull | TFolderThe parent folder of the file.
(Inherited from TAbstractFile)
pathstringThe path of the file.
(Inherited from TAbstractFile)
savingbooleanWhether the file is being saved.
statFileStatsThe stats of the file.
vaultVaultThe vault.
(Inherited from TAbstractFile)

Methods

MethodReturnsDescription
cache(content)voidCaches file's content, that can be retrieved via await app.vault.cachedRead(file).
getNewPathAfterRename(newName)stringGets the path after renaming the file or folder.
(Inherited from TAbstractFile)
getShortName()stringGets the short name of the file.

For a/b/c.md, it returns c.

For a/b/c.any-other-extension it returns c.any-other-extension.
setPath(path)voidSets the path of the file or folder.
(Inherited from TAbstractFile)
updateCacheLimit()unknownRemoves the file from the cache if its content length greater than app.vault.cacheLimit.

Links to this page: