Your solution looks great, but when I implement it, the Path only reveals a subset of the entire folder path. For example, if my path is /Users/home/Dropbox/CapData/RawFileName/1994/filename.csv, I’m getting “/Users/home/Dropbox/CapD”. I’ve searched around for a solution, but cannot figure it out.
Thanks for this macro. Quick question, when I use it with Path Finder it gives me the UNIX path for the file, excluding its name. I presume this is what it’s meant to do.
So for example, running the macro a result might be /Documents/Personal/Finances/Letters/
What I would like is the filename as well e.g. /Documents/Personal/Finances/Letters/letter to bank.doc
I see the same output as duncmac - there is something in the regex that is cutting the file/folder name after the parent path. If I use the PathFinder menu directly (or delete the regex step, I get the whole thing too.
BUT, the macro name is Copy CONTAINER Folder…, so I think the macro is doing exactly what it is designed to do. If you want the entire path to the file, just delete the regex step in the macro.
If you want to get the Unix path of a file/folder into the clipboard in Path Finder, all you have to do is Copy (Cmd-C).
If you want to use those paths in a macro then it's faster to get them with AppleScript.
------------------------------------------------------------
# Get Posix Paths of Selected Items in Path Finder
# Assign a Keyboard Maestro variable to the value.
------------------------------------------------------------
set pfSelList to missing value
tell application "Path Finder"
set pfSelList to selection
if pfSelList ≠ {} then
repeat with i in pfSelList
set (contents of i) to POSIX path of (contents of i)
end repeat
end if
end tell
if pfSelList ≠ missing value then
set AppleScript's text item delimiters to linefeed
set pfSelList to pfSelList as text
tell application "Keyboard Maestro Engine"
try
set value of variable "myVariableName" to pfSelList
on error
make new variable with properties {name:"myVariableName", value:pfSelList}
end try
end tell
end if
------------------------------------------------------------
Look in Keyboard Maestro's Help menu for the 'ICU Regular Expression Reference' item and select it.
Learning regular expressions takes some effort. It appears very intimidating at first, but simple regex is really very easy to learn. Complex regex usage though is something one never masters entirely — I'm still learning new things after over 20 years of using them.
If you're serious then you'll want to buy a book or two.
You can learn a lot about regular expressions online, but there are many flavors. They don't all work the same, and that can be very confusing to newbies.
Scope out the resources on the Keyboard Maestro wiki as a start.
Very nice and thankx. It’s sometimes so natural to go off programming something or looking for special KM actions that something as simple as this doesn’t present itself.
To get the filename without the path, just add parentheses around the second .*. You’ll see a field for a second capture group – that will be the file name with no path.
Hi, I'm trying to find a method of extracting a valid path from theDroppedItems (coming in from AppleScriptEditor). I tried reading this but have been unable to do it.
I'm hoping to use the path in theDroppedItems (the full folder-path, not the full folder&file-path) and copy it to the clipboard.
There will be only one file. Is this complex to do?