14

How can I copy the path to a folder or a file? The Info Dialog doesn't allow me to copy the information that stands there ...

alt text

Is there an easy way to do this?

10 Answers 10

13

Right click on the file, hold down Alt/Option, and an item to copy file path will appear as Copy "<FILENAME>" as Pathname.

This is the easiest option for day to day usage, without involving Automator.

This seems to be a relatively new feature that was added in OS X El Capitan. (It also works on macOS Sierra).

8

There are two ways I do this (and the info window is neither of them):

  1. Open the Terminal application and drag the item into the window, and a POSIX-style path will be displayed that you can copy and paste.
  2. Use Applescript...

...select an item in the Finder and run this...

tell application "Finder"
    return info for selection as alias
end tell

...or create a droplet with this code...

on open theFile
   set thePath to POSIX path of theFile
   set the clipboard to thePath as text
end open

Add salt to taste.

8

As already described by ayaz, the Get Info window (cmd+i) has the full path and will allow you to copy it. If you tripple click in the highlighted area (by the red rectangle) the selection will automatically expand to the whole path. cmd + c will suffice to copy it to the clipboard.

get info window

If you need the path to interact with the Terminal, you can always check one of the “zillion” answers in this Stack Overflow Question.

UPDATE: This method seems to be only valid for OS X 10.6.x, previous OS X versions used the non-POSIX path style that looked like path:to:file, whereas the POSIX would be path/to/file. If you are in something older than OS X 10.6, you will have to try one of the other methods described in the other answers (or upgrade to 10.6 ;)

  • I don't know why but this doesn't work for me. There is no selection at all in this dialog. – Pierre Watelet Sep 29 '10 at 15:33
  • What OS version do you have? – Martin Marconcini Sep 29 '10 at 19:15
  • This doesn't work for me either, running 10.5.8 – KeithB Sep 29 '10 at 20:35
  • The info method not working might be a 10.5 vs. 10.6 issue. I just noticed for the first time that the path displayed is POSIX style and not the long-standing "path:to:file" style. – Philip Regan Sep 29 '10 at 20:42
4

The best and easiest way to do this is by creating a "copy path" service, very similar to the shift + Right-Click on a Windows machine.

If you frequently need to copy and paste file and folder paths, creating an Automator Service will make your life easier because the service then becomes accessible from the OS X Right-Click contextual menu, accessible from anywhere in the Finder.

Follow these steps to set it up (screenshots below).

  1. Launch Automator
  2. Create a new “Service”
  3. Use the search function to look for “Copy to Clipboard” and drag that into the rightsize panel of the Service Set ‘Service receives selected’ to “files or folders” and ‘in’ to “Finder”.
  4. Save the Service with a name like “Copy Path”.

    enter image description here

The result:

enter image description here

You'll now have the textual path in your clipboard.

Sources: CNet, OSX Daily

  • This should be the correct answer. Shame that Apple did not enable such a simple conf as the default ... It took MSFT 5 years to implement the copy as path right menu item after countless regedit and dll hacks were invented by the community ... such a good example of the fact that big companies do not really study carefully the needs of their customers ... – Yordan Georgiev Nov 25 '17 at 22:14
  • In Mojave, Service is now called Quick action (a great innovation, goes without saying.) – Fabien Snauwaert Dec 15 '18 at 13:57
2

Simply drag the file into text editor, and it will give you the full path for that file.

1

I will move my comment over as an answer.

You should be able to copy the path to a folder/file by highlighting the value next to "Where:" in the info dialog and pressing CMD+c.

An easier alternative that requires less effort is right-clicking on that value, and clicking "Copy" in the drop-down that appears.

1

Sometimes the solution is so simple.

Just mark the file in the finder and then press Command-C. The path including the file name is copied to the clipboard and you can paste it in any application.

  • I just got the filename in the clipboard. How Do You get the full path ? – Pierre Watelet Oct 5 '10 at 11:47
  • 2
    In the finder, click once on the filename or the icon so that the file is highlighted (if you can change the filename now, you clicked to often and you must press Escape to cancel the rename operation). Then press Command-C. – Hanspeter Oberlin Oct 5 '10 at 19:29
  • doesn't work for me either, just the filename is copied. – Robert S Ciaccio Oct 6 '10 at 18:28
  • I just checked it. It works when pasting into Terminal but not into TextEdit. Dragging and dropping a file into Terminal pastes the filename and path. Dito in TextEdit. What about other applications? – Hanspeter Oberlin Oct 7 '10 at 4:32
1

This is how to create a Service to copy to the clipboard the selected paths in Finder:

  1. Open Automator. Press ⌘+N and choose Service.
  2. Set "Service receives selected files or folders in Finder.app".
  3. Drag the element "Run Shell Script" to the window.
    Note: You can select this element if you go to the left of the window and click on Actions, Library, and type part of the name in the search box.
  4. Set "Shell: /bin/bash", "Pass input: as arguments" and type the following in the script box: for f in "$@" do echo "$f" done.
  5. Drag the element Copy to Clipboard.
  6. Save your service in ~/Library/Services/Copy POSIX Paths.workflow (or any other name you like).

Now you will be able to run this service if you right click an element and choose Services > Copy POSIX Paths. It will copy the file(s) selected in Finder to your clipboard. I tested this on Lion.

Automator

I got this tip from Kris Johnson's Blog.

1

Starting in El Capitan (OS X v10.11), this is really easy:

  1. Select the item(s) in the Finder
  2. Press Command-Option-C (or hold the Option key down and choose Edit menu > Copy [whatever] as Pathname.
  • There really needs to be a way to pin this to the top as "Best Answer Which Was Not Available At Time When Question Was Asked." – TJ Luoma Oct 9 '18 at 0:18
0
  1. Start automator
  2. Create a new service
  3. Set the service to acquire files and folder in the finder, and add the run applescript element
  4. Paste this script

    on run {input, parameters}
    set mylist to {}
    repeat with elem in input
        try
            set the end of mylist to (POSIX path of (elem as alias))
        end try
    end repeat
    set oldtid to AppleScript's text item delimiters
    
    
    set AppleScript's text item delimiters to {return}
    set flatlist to mylist as text
    
    
    set AppleScript's text item delimiters to oldtid
    
    
    tell application "Finder" to set the clipboard to flatlist
    
    
    -- code below will also create an email with the path inside. delete it if you don't want that.
    tell application "Microsoft Entourage"
        set theMessage to make new outgoing message with properties {subject:myFileName, content:flatlist}
        open theMessage
        activate
    end tell
    end run
    
  5. Save the result as 'copy and email path' or something.
  6. Now check your ctrl-click menu and your services menu. Nice!

You must log in to answer this question.

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