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.

This surely sounds weird to PC users ;-), but my actual question is "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 that ?

share|improve this question
2  
Are you not able to highlight the value next to "Where:" and press CMD+c to copy it? –  ayaz Sep 29 '10 at 11:39
    
@ayaz consider writing that as an answer, since it's probably the best way to do what he's asking :) –  Loïc Wolff Sep 29 '10 at 11:54
    
which version are you on? If I right click on the path, I get the standard edit menu with Copy in it –  Victor Jalencas Sep 30 '10 at 13:59
add comment

7 Answers 7

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.

share|improve this answer
2  
Any application that cannot receive files or file contents after a drap and drop will give you the filename instead. So this not only works with Terminal, but also with TextEdit or other "simple" apps. –  Jan Fabry Sep 30 '10 at 10:17
add comment

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 ;)

share|improve this answer
    
I don't know why but this doesn't work for me. There is no selection at all in this dialog. –  Rabskatran Sep 29 '10 at 15:33
    
What OS version do you have? –  Martín 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
add comment

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.

share|improve this answer
    
Doesn't work for me... –  Rabskatran Sep 29 '10 at 12:26
add comment

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.

share|improve this answer
    
I just got the filename in the clipboard. How Do You get the full path ? –  Rabskatran 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
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment
  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!
share|improve this answer
add comment

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.