Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.6: Create a Service to copy a file path URL to the clipboard' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Create a Service to copy a file path URL to the clipboard
Authored by: ihadmeavision on Dec 04, '09 02:00:09PM

I tried this one and I only get the parent folder's path. The original post above works great but I also don't want the file://. I'm running 10.6.2 if that makes any difference. Great hint by the way.



[ Reply to This | # ]
10.6: Create a Service to copy a file path URL to the clipboard
Authored by: shemp9999 on Dec 04, '09 11:43:44PM
to get a full space and quote escaped POSIX path, try this (Useful for terminal, omits 'file:' prefix).
sed -e 's/:/\//g' -e 's/\ /\\ /g' -e "s/\\'/\\\'/g"  -e 's/\"/\\"/g' | pbcopy
Add expressions for other exotic characters as needed.

[ Reply to This | # ]
10.6: Create a Service to copy a file path URL to the clipboard
Authored by: ihadmeavision on Dec 08, '09 07:38:47AM

Works great now. Thank you so much!



[ Reply to This | # ]
10.6: Create a Service to copy a file path URL to the clipboard
Authored by: bretperry on Jan 27, '10 01:40:31PM

Cool. And works great in most cases, but not for BASH if the Mac file path includes a slash. I know, shouldn't use slashes but we're in a big company and Mac lets you put a slash in File + Folder names, so people do...

This works OK for Forward slashes and back-slashes in the Mac Filename (quotes whole path):

on run {input}
set input to POSIX path of input
set input to "\"" & input & "\""
return input
end run

then add a copy to clipboard action
Maybe someone knows a more elegant way to do this in a shell script?





[ Reply to This | # ]
10.6: Create a Service to copy a file path URL to the clipboard
Authored by: broz on Mar 18, '10 10:43:00AM
This works, but always adds a newline to the end. This is VERY annoying when pasting into the Terminal, as it executes the command you're trying to create. I added at tr -d "\n" to the end
sed -e 's/:/\//g' -e 's/\ /\\ /g' -e "s/\\'/\\\'/g" -e 's/\"/\\"/g' | tr -d "\n" | pbcopy
which fixes that problem. This Automator command does nothing about the selection of multiple items in the Finder. All the paths get copied, and land in the clipboard. I don't want them all pasted into the Terminal, but might want them pasted somewhere else. In that case, the tr bit on the end will not be what you want.

[ Reply to This | # ]