Skip to content

@sqlrooms/utils / splitFilePath

Function: splitFilePath()

splitFilePath(filePath): object

Splits a file path into its directory, name, and extension components.

Parameters

ParameterTypeDescription
filePathstringThe full file path to split

Returns

object

An object containing the directory path, file name (without extension), and extension

NameType
dirstring
namestring
extstring
filenamestring

Example

ts
splitFilePath("path/to/file.txt") // returns { dir: "path/to", name: "file", ext: "txt" }