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

Property Type Description
basename string The basename of the file (name without extension).
deleted boolean Whether the file or folder is being deleted.
(Inherited from TAbstractFile)
extension string The extension of the file.
name string The name of the file (with extension).
parent null | TFolder The parent folder of the file.
(Inherited from TAbstractFile)
path string The path of the file.
(Inherited from TAbstractFile)
saving boolean Whether the file is being saved.
stat FileStats The stats of the file.
vault Vault The vault.
(Inherited from TAbstractFile)

Methods

Method Returns Description
cache(content) void Caches file's content, that can be retrieved via await app.vault.cachedRead(file).
getNewPathAfterRename(newName) string Gets the path after renaming the file or folder.
(Inherited from TAbstractFile)
getShortName() string Gets 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) void Sets the path of the file or folder.
(Inherited from TAbstractFile)
updateCacheLimit() unknown Removes the file from the cache if its content length greater than app.vault.cacheLimit.

Links to this page: