| url | https://sqlrooms.org/api/utils/functions/splitFilePath.md |
|---|
@sqlrooms/utils / 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).
| Parameter | Type | Description |
|---|---|---|
filePath |
string |
The full file path to split |
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 |
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" }