I’m trying to make an automator file/folder service that will copy the URL link of a selected file or folder to my clipboard. The purpose of this is so that I can ctl+click on a file/folder and chose this service and then be able to IM the link to a fellow co-worker.
(* this changes the Applescript path to a POSIX path *)
on run {input, parameters}
set newPath to (the POSIX path of input)
get replaceSpaces(" ", "%20", newPath)
end run
(* this replaces all spaces with "%20" and adds "file://" prefix *)
on replaceSpaces(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
set subject to "" & subject
set text item delimiters of AppleScript to prevTIDs
set filePrefix to "file://"
return filePrefix & subject
end replaceSpaces