Thanks @ccstone this works wonderfully. It is now in production, thanks for sharing.
Hey Folks,
Point to note:
As of Keyboard Maestro 8 the New Folder Action is capable of creating intermediate folders.
I.E. if any parent folders between the start and the end of the path don't exist they will be created along with the new folder.
Without “intermediate folders” switched ON the action will fail if any parent-level folders in the path to the desired new folder don't exist.
I still prefer doing this job with AppleScript, because it enables UNDO in the Finder and the KM action doesn't.
But – now I've discovered the action can create intermediates I'm much more likely to use it when undo isn't important to me.
-Chris
Make New Folder -- With Intermediate Folders If Needed v1.00.kmmacros (6.1 KB)
AI to the rescue I was able to figure out what needed to change when referencing a path retreaving a variable in Keyboard Maestro. The old code is commented out.
Execute an AppleScript Action (v10.2)
Execute an AppleScript.kmactions (1.2 KB)
Also for what it is worth if you use this code and move between drives it will keep the original where it is and copy. If you want the file to actually move you can use the following AppleScript.
set destinationAlias to alias ((path to home folder as text) & "test_directory:FOLDER-01:")
# Move the items selected in the Finder.
tell application "Finder"
set selectedItemList to selection as alias list
repeat with itemRef in selectedItemList
duplicate itemRef to destinationAlias
delete itemRef
end repeat
end tell