Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

It's very annoying to always have to open the Information about... window to get the path of a folder or a file.

Is there something like a contextual menu to get the url or the path of any file or folder?

share|improve this question
    
cmd+I? Or having finder show the file path bar? Or right clicking the file icon in the Finder window? –  Andrew U. Feb 6 at 16:50
    
I meant cmd+i. Thanks –  Colas Feb 6 at 17:29

2 Answers 2

up vote 5 down vote accepted

This is sort of easy.

Select the file and then Command-C will put the path to the file in the clipboard. If you then paste into the Terminal you will get the entire path, unfortunately most other apps you will just get the filename.


If you want the full path then you can create an Automator Service to do it easily :-

enter image description here

Create a new Automator service and change the 'Service receives Selected' to : Files or folders And the in to the Finder application.

Add a Copy to Clipboard Action and Save the Service.

You can now select a file, right click to get a contextual menu and select your service in the Service submenu.

The path will be in the clipboard ready for you to paste. You can even set a keyboard shortcut for it if you like.

Originally I used a Run Applescript Action to get the Posix path to the file and pass it on to the Copy to Clipboard Action.

But I discovered all you needed is to have the selection passed directly to the Copy to Clipboard Action.

This improved on the Applescript because the Applescript could only deal with one item being selected as written.

But now you can select multiple files and get multiple paths in the clipboard without writing any code.

share|improve this answer
2  
For using the path in Terminal it's easier if you just drag the file / folder into the Terminal's window. –  Thecafremo Feb 5 at 8:32
    
@TonyWilliams, Good spot on the only using the Copy to clipboard Action. I would like to vote your answer up but first, can I suggest you edit your answer to Just reflect that. The applescript you use will break if more than one item is selected. And your discovery covers both single and multiple options. –  markhunte Feb 5 at 20:27
    
@markhunte Unfortunately I'm at work without a Mac for the next eight hours to put in a new screen shot. Might manage it at lunch :) otherwise it's when I get home tonight. –  Tony Williams Feb 5 at 22:39
    
@TonyWilliams, Sorted. –  markhunte Feb 5 at 23:40
    
@markhunte Thanks. I was just about to go and "fix" a computer in the Student Office so I could get 15 minutes on a Mac. –  Tony Williams Feb 6 at 2:25

You can assign a shortcut to a script like this:

tell application "Finder" to set s to selection as alias list
if s is {} then return
set out to ""
repeat with f in s
    set out to out & POSIX path of f & linefeed
end repeat
set the clipboard to out

There was a bug in 10.7 and 10.8 that made it difficult to get the selection property reliably, but it was fixed in 10.9. (Finder ignored windows that were created after the last time focus was moved to another application and back.) If you use 10.7 or 10.8, add these lines to the start of the script:

activate application "SystemUIServer"
activate application "Finder"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.