AppleScript to copy UNIX path of currently selected file in Pathfinder to clipboard

Hello,
It’s simple to copy the UNIX path of currently selected file in Pathfinder to the clipboard while I am in Pathfinder, but is it possible to create a script to copy that path to clipboard when I am in another app such as Bear or Evernote or Scrivener?
thanks in advance for your time and help

I don’t use Pathfinder, but in the Finder there’s a keystroke to copy the selected file’s Unix path (I think it’s command-option-c, but I’m not positive). I have to believe Pathfinder has done something similar, given that it’s supposed to extend the capabilities of the Finder.

Try this. It’s based on something I use in combination with Sublime Text, Keyboard Maestro (plus a bit of shell script) and my Stream Deck for processing a selected image file in Path Finder, and then inserting some details directly into my editor application; rather than onto the clipboard.

tell application "Path Finder"
	set thePaths to {}
	repeat with pfItem in (get selection)
		set the end of thePaths to POSIX path of pfItem
	end repeat
end tell

set the clipboard to item 1 of thePaths

Hope that helps.

1 Like

works perfectly !! you are a genius !!
thank you so much !

Hi, there is a misunderstanding. The problem is to copy the currently selected file in pathfinder to the clipboard when you are not in pathfinder, ie when you are in any app.
@sylumer provided me with a superb and far from obvious solution. He is brilliant !

if it’s not asking too much, how would I modify the script to copy the URL path instead of the UNIX path ?
thanks again

For example:

on run
    tell application "Path Finder"
        set selns to selection
        if missing value ≠ selns and {} ≠ selns then
            set urlString to URL of (item 1 of selns)
            set the clipboard to urlString
            return urlString
        else
            return "Nothing selected in Path Finder"
        end if
    end tell
end run
1 Like

great ! thank you very much. I am very sorry for the delayed response.