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


Click here to return to the '10.4: A simple way to copy the path to a file or folder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: A simple way to copy the path to a file or folder
Authored by: junge on Oct 04, '11 04:54:55AM
Now it's Mac OS X 10.7 but I guess this is still relevant. What I do is I use FTP client Transmit from Panic. This may not be a practical solution to everyone but since I have it running all the time it's really easy and practical for me: Browse to the desired file or folder, local or remote, in the Transmit window, and CTRL-click to choose 'Copy URL' or 'Copy Path'. Copy URL will copy something like this to your clipboard:
file://localhost/Users/michael/Pictures/picture1.jpg
and Copy Path something like this:
/Volumes/Macintosh HD/Users/michael/Desktop/Pictures/picture1.jpg


[ Reply to This | # ]
10.4: A simple way to copy the path to a file or folder
Authored by: NatCk on Nov 21, '11 11:06:25PM
Bumping this thread since I couldn't find another post on this and had to piece it together myself. To get a clickable file url for any file or folder with just applescript, you can use the following code. Basically, it changes the text delimiter for filename spaces from " " to "%20". Then it prepends the POSIX location with the "file://" and copies the result to the clipboard.

on ReplaceText(theString, fString, rString)
	set current_Delimiters to text item delimiters of AppleScript
	set AppleScript's text item delimiters to fString
	set sList to every text item of theString
	set AppleScript's text item delimiters to rString
	set newString to sList as string
	set AppleScript's text item delimiters to current_Delimiters
	return newString
end ReplaceText

tell application "Finder"
	set thisFile to selection as alias
	set FilePath to "file://" & POSIX path of thisFile
	set FileURL to ReplaceText(FilePath as string, " ", "%20") of me
	set the clipboard to FileURL
end tell


[ Reply to This | # ]