Skip to content

Instantly share code, notes, and snippets.

@armadillu
Forked from kitschpatrol/copy-path-to-clipboard.scpt
Last active December 22, 2015 21:09
Show Gist options
  • Save armadillu/6531257 to your computer and use it in GitHub Desktop.
Save armadillu/6531257 to your computer and use it in GitHub Desktop.
takes selected item from frontmost finder window, makes a smb:// link to the file and copies it into the clipboard Just go an paste it into your email! Whoever clicks on that link, will be automatically connected to that server and directed to that file. It also bypasses login window. Only for LP people!
-- csipttc_unisiwc_ctpttfwttc.app
-- Copy Selected Items Path To The Clipboard Unless Nothing Is Selected In Which Case Copy The Path To The Foremost Window To The Clipboard
on makeAndCopyLinkFromPath(myPath)
if myPath starts with "/Volumes/" then
set dirStructure to ((characters 9 thru -1 of myPath) as string)
set strHTML to quoted form of ("<a style='font-family:helvetica' href=\"smb://Guest::@lp-vault" & dirStructure & "\">" & myPath & "</a>") --double :: bc otherwise it disappears?
--tell application "Finder" to display dialog strHTML
do shell script "echo " & strHTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
else
display dialog "Make Sure you select an item in the Vault." buttons {"Ok"} with icon caution with title "Error"
end if
end makeAndCopyLinkFromPath
try
tell application "Finder"
set selectedItem to (POSIX path of (the selection as alias))
my makeAndCopyLinkFromPath(selectedItem)
end tell
on error
try
tell application "Finder"
set selectedItem to (POSIX path of (target of front window as alias))
my makeAndCopyLinkFromPath(selectedItem)
end tell
on error
display dialog "Unable to copy a path to the clipboard. Make sure Finder is referencing a directory/folder within the file system." buttons {"Ok"} with icon caution with title "Error"
end try
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment