Action "Split Path" returns _relative_ when path comes from Path Finder via Applescript

I am incorporating the new-in-v.8 “Split Path” Action in some old and new macros. It is returning “/Nowhere” when I expect it to return the parts of the path. From Keyboard Maestro’s Wiki I learn that this is likely due to the path being relative when an absolute path is required.

The problem seems to be how I get the path.

When I load the path from a Finder dialog popped-up from the “Split Path” Action, “Split Path” works as expected.

I use Path Finder and regularly use an “Execute AppleScript” Action (which I got here) to create a text list of the files currently selected in Path Finder. I use a “For Each” Action to get the paths.

The paths show correctly in the variable viewer in Keyboard Maestro preferences.

Files selected in Path Finder: MySelectedFile1.ext MySelectedFile2.ext

“pathList” (variable) shown in Keyboard Maestro: /Volumes/VolumeName/TopLevelFolder/ChildFolder/MySelectedFile1.ext /Volumes/VolumeName/TopLevelFolder/ChildFolder/MySelectedFile2.ext

“Path” (variable) shown in Keyboard Maestro:
This matches (afaict) what “Split Path” Action shows when the file is selected in Finder.
(File “2” shows because the “For Each” Action has been run to load the paths to the “Path” variable.)

“Split Path” Action “Parent to” returns “/Nowhere”.

I add in case it is important: my actual file names are long and have spaces, dashes, plus signs, underscores, @'s, and apostrophes.

It seems to me I am missing something so basic as to hardly justify this write-up. I have had no problems with the AppleScript or the “For Each” Actions before. (I have used “Get Parent to Variable” and “Get Base Name to Variable” in the past.)

O bang me on the head with a passel of percent signs!

I need to use %Variable%Path% in the “Split path” field of the “Split Path” Action. I had been using just the name of the variable, i.e.: Path.

I understand that it didn’t work because the field expects text, and so understood “Path” literally (not as a variable).

Kudos to Peter for putting the little “Field Input Type” markers in the fields. This is what allowed me to imagine my error.


Leaving this as it seems possible useful to others. Feel free to delete the thread.

1 Like