Getting Finder paths HFS and POSIX via Applescript

56 views
Skip to first unread message

Vince

unread,
Jan 18, 2019, 11:21:47 PM1/18/19
to SuperCard Discussion
SC 4.81 contains ability to drag a file to Message bar and you will get the full path to the file. But you still have to select and copy it from messages.
Prior to this I have used applescript to provide this function using scripts I trigger with Keyboard Maestro. 

The scripts will return the full path to a single file and will return comma-separated paths if you have multiple files selected in the Finder. Best part is, results are copied to clipboard so you can just paste the results into your script.  Might be helpful if SC 4.81 also saved to clipboard?

NOTE: these are applescripts so you will have to copy into Script Editor and compile/save as an app. To run, launch applescript app with Spotlight, or if you have Keyboard Maestro, put the script into an "execute applescript' macro step.

——APPLESCRIPT———

-- returns POSIX path of files selected in Finder

-- with multiple files selected, returns results as comma separated list

tell application "Finder"

set finder_sel to the selection as alias list

end tell

set file_list to {}

set mylist to ""

repeat with x in finder_sel

set file_list to file_list & ((x) as string)

end repeat

repeat with x in file_list

set mylist to mylist & quote & POSIX path of x & quote & ","

end repeat

set mylist to characters 1 through -2 of mylist as string

set the clipboard to mylist



——Applescript————

-- returns HFS path of files selected in Finder

-- with multiple files selected, returns results as comma separated list

tell application "Finder"

set finder_sel to the selection as alias list

end tell

set file_list to {}

set mylist to ""

repeat with x in finder_sel

set file_list to file_list & ((x) as string)

end repeat

repeat with x in file_list

set mylist to mylist & quote & x & quote & ","

end repeat

set mylist to characters 1 through -2 of mylist as string

set the clipboard to mylist

codegreen

unread,
Jan 19, 2019, 1:35:31 AM1/19/19
to SuperCard Discussion
If the goal is to get the file's path into a script, you can just drag it into the script editor.

-Mark

Vince

unread,
Jan 19, 2019, 11:11:43 AM1/19/19
to SuperCard Discussion
Oh sure, Mark, just take the easy way out! ;)

V
Reply all
Reply to author
Forward
0 new messages