Skip to content

Instantly share code, notes, and snippets.

@lsfalimis
Last active March 12, 2017 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lsfalimis/6677b66fbea061bf5eb5 to your computer and use it in GitHub Desktop.
Save lsfalimis/6677b66fbea061bf5eb5 to your computer and use it in GitHub Desktop.
Copy the paths of Finder files and folders
(*
if select multiple items, copy paths of them with one in each line;
if select an item, copy its path;
if none is selected, copy the current folder path.
*)
tell application "Finder"
set sel to the selection
if (count of sel) is greater than 1 then
set theList to ""
repeat with e in sel
set theList to theList & POSIX path of (e as text) & return
end repeat
set the clipboard to theList
else if (count of sel) is equal to 1 then
set the clipboard to POSIX path of (sel as text)
else
set the clipboard to POSIX path of (target of window 1 as alias)
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment