12

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?

2
  • cmd+I? Or having finder show the file path bar? Or right clicking the file icon in the Finder window?
    – Andrew U.
    Commented Feb 6, 2014 at 16:50
  • 2
    select the file and then click while holding the alt(option) key: see "copy <name>" as pathname.
    – LexS
    Commented Nov 1, 2015 at 16:11

3 Answers 3

10

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.

9
  • 2
    For using the path in Terminal it's easier if you just drag the file / folder into the Terminal's window.
    – Thecafremo
    Commented Feb 5, 2014 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
    Commented Feb 5, 2014 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. Commented Feb 5, 2014 at 22:39
  • @TonyWilliams, Sorted.
    – markhunte
    Commented Feb 5, 2014 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. Commented Feb 6, 2014 at 2:25
14

On OS X "El Capitan",

Option+Command+C the selected file/folder

OR

  1. option right click the file/folder (in Finder)

  2. Select 'Copy "file/folder" as Pathname'.

Copy "file/folder" as Pathname

Copy file path in Finder

You now have the option to copy the path to a file without copying the file itself, perfect for working with files stored on a server. To copy the file path, right-click the file in the Finder, and then hold the Option key down and choose Copy as Pathname.

(From Apple) http://www.apple.com/osx/all-features/#other-features

1
  • I had a service for this, but it was buggy. +1 for mentioning El Capitan added this; did not know Commented Dec 25, 2015 at 8:20
1

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"

Not the answer you're looking for? Browse other questions tagged .