sqlrooms.github.io/api/utils/functions/splitFilePath.md at main · sqlrooms/sqlrooms.github.io · GitHub
Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 994 Bytes

File metadata and controls

37 lines (26 loc) · 994 Bytes
url https://sqlrooms.org/api/utils/functions/splitFilePath.md

@sqlrooms/utils / splitFilePath

Function: splitFilePath()

splitFilePath(filePath): object

Splits a file path into its directory, name, and extension components. Preserves the original path separator style (Windows backslashes or Unix forward slashes).

Parameters

Parameter Type Description
filePath string The full file path to split

Returns

object

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

Name Type
dir string
name string
ext string
filename string

Example

splitFilePath("path/to/file.txt") // returns { dir: "path/to", name: "file", ext: "txt", filename: "file.txt" }
splitFilePath("C:\\Users\\file.txt") // returns { dir: "C:\\Users", name: "file", ext: "txt", filename: "file.txt" }