------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2010/10/06 06:43
# dMod: 2017/04/29 17:32
# Appl: Finder
# Task: Get posix path of selected item(s) or if none the front window and copy to clipboard.
# Libs: ELb
# Osax: None
# Tags: @Applescript, @Finder, @Posix, @Path, @Selection, @Clipboard
------------------------------------------------------------------------------
try
set AppleScript's text item delimiters to linefeed
tell application "Finder"
set finderSelectionList to paragraphs of (selection as text)
if length of finderSelectionList = 0 then
set finderSelectionList to insertion location as text as list
end if
end tell
if length of finderSelectionList > 0 then
repeat with theAlias in finderSelectionList
set theAlias's contents to POSIX path of theAlias
end repeat
set finderSelectionList to finderSelectionList as text
set the clipboard to finderSelectionList
end if
on error e number n
stdErr(e, n, true, true) of me
end try
------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on stdErr(e, n, beepFlag, ddFlag)
set e to e & return & return & "Num: " & n
if beepFlag = true then
beep
end if
if ddFlag = true then
tell me
set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
end tell
if button returned of dDlg = "Copy" then set the clipboard to e
else
return e
end if
end stdErr
------------------------------------------------------------------------------