Skip to content

obsidian/file-system

This module provides utility functions for working with TAbstractFile, TFile, and TFolder instances in Obsidian.

InterfaceDescription
ExistsParamsParameters for exists.
GetAbstractFileOrNullParamsParameters for getAbstractFileOrNull.
GetAbstractFileParamsParameters for getAbstractFile.
GetFileOrNullParamsParameters for getFileOrNull.
GetFileParamsParameters for getFile.
GetFolderOrNullParamsParameters for getFolderOrNull.
GetFolderParamsParameters for getFolder.
GetMarkdownFilesParamsParameters for getMarkdownFiles.
FunctionDescription
asArrayOfFilesConverts an array of abstract files to an array of files.
asArrayOfFoldersConverts an array of abstract files to an array of folders.
asFileConverts an abstract file to a file.
asFileOrNullConverts an abstract file to a file or null.
asFolderConverts an abstract file to a folder.
asFolderOrNullConverts an abstract file to a folder or null.
checkExtensionChecks if the given path or file has the specified extension.
existsChecks if the given path exists.
getAbstractFileRetrieves the TAbstractFile object for the given path or abstract file.
getAbstractFileOrNullRetrieves an abstract file or null based on the provided path or abstract file.
getFileRetrieves a file based on the provided path or file.
getFileOrNullRetrieves a file or null based on the provided path or file. If the provided argument is already a file, it is returned as is. Otherwise, the function uses the app’s vault to retrieve the file by its path.
getFileSystemTypeGets the type of a file system object.
getFolderRetrieves a folder based on the provided app and pathOrFolder.
getFolderOrNullRetrieves a folder or null based on the provided path or folder.
getMarkdownFilesRetrieves an array of files representing the markdown files within a specified folder or path.
getOrCreateFileRetrieves the file for the given path or creates a new one if it does not exist.
getOrCreateFolderRetrieves the folder for the given path or creates a new one if it does not exist.
getPathReturns the path of the given pathOrFile.
isAbstractFileChecks if the given file is an instance of abstract file.
isBaseFileChecks if the given file is a base file.
isCanvasFileChecks if the given file is a canvas file.
isFileChecks if the given file is an instance of file.
isFolderChecks if the given file is a folder.
isMarkdownFileChecks if the given file is a Markdown file.
isNoteChecks if the given file is a note.
trimMarkdownExtensionTrims the markdown extension from the file path if the file is a markdown file. If the file is not a markdown file, the original file path is returned.
TypeDescription
PathOrAbstractFileA path or an abstract file.
PathOrFileA path or a file.
PathOrFolderA path or a folder.
EnumDescription
FileSystemTypeA type of file system object.
VariableDescription
BASE_FILE_EXTENSIONA file extension for base files.
CANVAS_FILE_EXTENSIONA file extension for canvas files.
MARKDOWN_FILE_EXTENSIONA file extension for markdown files.