Hi, I’m trying to create 3 folders in the currently active tab of PathFinder 7. I know I can use the variable %FinderInsertionLocation% to get the one from Finder, but since I’m using Pathfinder, I’m not sure how to do it. Currently, I’m doing the keyboard shortcut for a new folder and pasting the name I want, then enter. I’m doing this 3 times since that’s what I need for now but I’m sure there is a better way to do this than that. Any ideas?
You can use this AppleScript to get path to the directory currently displayed in Path Finder's front tab:
tell application "Path Finder"
tell its finder window 1
POSIX path of target
end tell
end tell
You can use this in KeyBoard Maestro like this:
WOW, that works! thanks svenl!
svenl, you wouldn’t know how to get the selection of files in Path Finder, wouldn’t you?
The goal is to select a bunch of files and move them in those folders. So every Tiff Goes in the Tiff folder, every psd in the psd folder and so one. But I want to select the files because sometimes I might have some tiff that would go into the Original folder and I’ll move them separately. I found something to move files according to their extension written by Peter in jul '14 but maybe there is something new that works better and with Path Finder. TIA!
oh man, I'm almost there. Two problems though.
First, it works on the content of the folder as in Peter example, not on my selection, although I could live with that.
Second, It doesn't like the space in one of my folder where I'm trying to move the tiff files. I've tried to put %20, escaping with a backslash, putting the name of the folder between quotes, nothing works.
PathFinder's selection can be accessed through "the selection" of Path Finder's application object:
set myResult to ""
tell application "Path Finder"
set theSelection to selection
repeat with myItem in theSelection
set myResult to myResult & POSIX path of myItem & return
end repeat
end tell
return myResult
To use it as as collection in Keyboard Maestro something like this should work:
I'm sorry, I can't help you with this.
Kind regards, Sven.
@svenl will know, but I think that the app has a selection method which returns a list:
JavaScript for Automation
(() => {
const pf = Application('Path Finder');
return pf.selection()
.map(x => x.posixPath())
})();
AppleScript
on run
tell application "Path Finder"
script
on |λ|(x)
POSIX path of x
end |λ|
end script
my map(result, selection)
end tell
end run
-- GENERIC FUNCTIONS ---------------------------------------------------------
-- map :: (a -> b) -> [a] -> [b]
on map(f, xs)
tell mReturn(f)
set lng to length of xs
set lst to {}
repeat with i from 1 to lng
set end of lst to |λ|(item i of xs, i, xs)
end repeat
return lst
end tell
end map
-- Lift 2nd class handler function into 1st class script wrapper
-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
if class of f is script then
f
else
script
property |λ| : f
end script
end if
end mReturn
Thanks again Sven, it works. And I found why the Tiff HR didn’t work, it was in the other IF statement which prevented it to work. So now I have two macros, one that works with a selection and one that doesn’t require a selection and works for the whole folder. Now I’ll know who to ask for Path Finder questions;-)
Thanks ComplexPoint, I think I know where you got your name;-). Man, I get a nose bleed just looking at your code;-) Way over my head here.