Split path
Splits a file path into its folder, name, name without extension and extension.
Split path into parts
Keyboard Maestro: SplitPath
Details #
Breaks a path into parts. It only works on the text of the path: the file does not have to exist and nothing on disk is read. A leading ~ is expanded to your home folder first.
For /Users/ana/Documents/report.final.pdf the parts are:
Directory:
/Users/ana/DocumentsName:
report.final.pdfBaseName:
report.finalExtension:
pdf
The output is an object with those four parts. If you give into, the step also sets variables: into holds the whole (expanded) path, and the parts go in intoDirectory, intoName, intoBaseName and intoExtension. With into set to f, you can use {{fName}} and {{fExtension}} in later steps.
Parameters #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
path | text | Yes | The path to split. Required. Supports variables and expressions. | |
into | text | The prefix for the variables described above. |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
- Split the path “~/Documents/report.final.pdf”
- Show “{{fBaseName}} is a .{{fExtension}} in {{fDirect…” for 3 s
Gotchas #
A name with no dot has an empty extension.
An empty path fails with "file.splitPath needs a path".
Like every step that is not marked safe, it is simulated in a dry run. The example turns on
dryRunSafebecause the step changes nothing.