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.

What's a quick way of copying the path to the directory that's currently open in Finder?

Copying that path is very easy in Linux and Windows file managers - you just need to copy it from the address bar. I don't see a corresponding option in Finder.

share|improve this question
3  
@AdamEberbach I disagree, the question you linked is about starting a Terminal instance at the current Finder path, this is about simply getting the path –  Kyle Cronin Apr 2 '12 at 4:05
2  
Can you explain what you mean by copying the path? Do you want it to the clipboard in expanded form /Volumes/whatever/path/to/frontmost/window/view or something else? Basically, what is the next step you are going to perform with the path once you have it? –  bmike Apr 2 '12 at 4:09
1  
@Adam: Not exactly. I'm looking for a quick method - similar to the ones I'm used to on Windows and Linux (i.e. either pressing a couple of keys or clicking and pressing a key or two). –  Hippo Apr 2 '12 at 4:22
1  
@TimothyMueller-Harder: Though that question is similar, there is a difference between getting the path for a file or folder in the Finder and getting the path for the active window, especially if something is already selected in that window. –  joelseph Apr 2 '12 at 22:22
1  
@BlankMan Here is the answer to your second question apple.stackexchange.com/questions/40194/… –  MrDaniel Aug 28 '12 at 12:38

14 Answers 14

Since Yosemite now has Windows-like dropdowns in Info window and this is the top Google result, here's what I came up with:

  1. Press Command + I to bring up Info window, the Comments and Preview sections will be expanded by default
  2. Drag Preview's folder icon into Comment's textbox
  3. Command + A, Command+X to cut the path to clipboard and undo the Comment change, Command + W to close
share|improve this answer

You can use Automator to do this with a single keyboard shortcut that you can use from any app, and without installing 3rd party software.

This Automator Service will copy the path of the Finder's front window, rather than the path of a selected file or folder, so it won't affect what windows are open or what items are selected. The path that is copied is simply text, so it can be pasted anywhere that you can paste text.

  1. Open Automator and create a new Service.
  2. Change "Service receives selected" to no input (or "files or folders" to have it appear from a right click) and leave it set to any application (unless you only want it to work from a specific app, like the Finder).
  3. Add a "Run AppleScript" action to the workflow.
  4. Replace (* Your script goes here *) with:

    try
        tell application "Finder" to set the clipboard to POSIX path of (target of window 1 as alias)
    on error
        beep
    end try
    
  5. Save the Automator Service with whatever name you'd like it to have in the Services menu.

This Automator Service will now be in your Services menu.

Note: This doesn't escape spaces, so if your path has spaces, you may need to quote it. For example, in Terminal, the path would need to be quoted, but in Finder's "Go to Folder" command, it would not. If you want it to copy as quoted, you can change POSIX path to quoted form of POSIX path.

Copy Finder Window Path Service

You can add a keyboard shortcut for the service by going to System Preferences > Keyboard > Keyboard Shortcuts, then click on "Services" in the left pane, then scroll down to the "General" section in the right pane until you find your service.

Copy Finder Window Path Keyboard Shortcut

share|improve this answer

Copy Path Finder Button is by far the easiest method I've found to accomplish this. It's so simple – download it, put in your Apps folder, then drag to your finder's toolbar, done.

share|improve this answer

I just made a quick Automator Action. The Get first Finder Window Path action will to get the front most Finder windows Posix Path. It a beta, but is working ok. 10.8 only It will return the Posix path of the front most open Finder window.

1, Open the zip and install it by double clicking on the action.

It will go into the Utilities Actions name 'Get first Finder Window Path'

2, drag it as normal to workflow area and add for example the 'Copy to Clipboard' action below it enter image description here

The Service selected can be file or folder if you save it as a'Service' this will enable you to then also use the contextual menu when clicking on any file or folder. doing so will run the actions and only return the Same window result. Not the selected file or folder. Alternatively set it to 'none.

You can save it as a service or like me save it as an Application and then drag the app into the finder windows Toolbar. Where you just have to click it. enter image description here

share|improve this answer

If you use Alfred, you can select the items, press ⌥⌘\, and select Copy path to Clipboard.

You could also assign a shortcut to a script like this:

tell application "Finder"
    set the clipboard to POSIX path of (insertion location as alias)
end

This would copy the paths of all selected items:

set l to {}
tell application "Finder" to repeat with f in (get selection)
    set end of l to POSIX path of (f as alias)
end repeat
set text item delimiters to linefeed
set the clipboard to (l as text)

There's a bug on 10.7 and 10.8 where the selection, insertion location, and target properties refer to the second frontmost window after opening a new window. It affects both scripts and Alfred, but not Automator services. As a workaround, you could move focus to another application and back before getting the selection:

activate application "SystemUIServer"
activate application "Finder"
share|improve this answer
1  
Good stuff; note that the bug also affects Alfred. If only selected items are needed (2nd script), you can avoid the bug by modifying the script to operate on input and by assigning it to an Automator-based Service that receives files or folders in Finder.app. To work around the bug when obtaining Finder's insertion location (1st script), you can apply the following, uuugly, but effective hack (works on 10.8.2): hide Finder, then unhide it again after a short delay - this will cause Finder to report the correct selection/insertion location afterward; obvious downside: flashing. –  mklement0 Oct 29 '12 at 13:05

On OS X, many things can be accomplished by dragging & dropping. Apple thinks you don't need to be able to access the file path conveniently because everything can be accomplished by drag & drop. I'm not completely of the same mind, but usually I can do what I want.

This is how common actions are performed on OS X where you would need a path in Windows or Linux.

  • To just find out where you are in Finder, right-click (or Command ⌘-click) the folder name in the title area.

  • In a file selection dialog, to navigate to an opened Finder location, drag the folder or any file from that folder onto the selection dialog. This will not move the file or folder like it does in Windows, but set the path of the File dialog instead. (You can also drag a the document proxy icon (from the title bar of most apps) or -drag items out of the Dock to do this.)

  • To get the path of a file in Terminal or another text-only Application, drag the file on the Terminal window.

What is not (easily) possible:

  • Inserting the file path of a file that is supported differently in an Application. For example, dragging an image into TextEdit (in RichText mode) will insert the image itself instead of the file path.
share|improve this answer
    
Potential confusion: Although command-click is the correct action for what you're describing, the term 'right click' in OS X conventionally refers to 'control-click'. –  applehelpwriter Jan 22 '13 at 11:55
    
@applehelpwriter It works with both Right-Click (which is [Ctrl]+Click) and [Cmd ⌘]+Click, so the sentence is absolutely correct, even though it was edited in by someone else –  dualed Jan 22 '13 at 14:39
    
Agreed, but I didn't read it that way. The expression "right-click (or Command click)" doesn't parse as two different options, which should be 'do A or B'. Rather, it looks like one option which is given an alternative name in parentheses. That's why I prefaced my comment with 'potential confusion'. –  applehelpwriter Jan 23 '13 at 10:34

The MacYourself tip Copy file or folder path to the clipboard in Mac OS X Lion works for me on 10.7.4. Basically it leads you through the steps of creating an Automator service that can be used to copy the full path of files and folders from the Finder. You then use it by assigning a custom hotkey or use the right-click menu to copy the path to the clipboard when a file or folder is selected.

enter image description here

If it helps, you can also type the following command into the Terminal to get the Finder to display the full path to the current folder in its titlebar:

defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

Use the following to turn it off again:

defaults write com.apple.finder _FXShowPosixPathInTitle -bool NO
share|improve this answer
    
Since you already have the AppleScript made (assuming that screen shot is yours), can you please upload it to a service like droplr.com and offer a direct download link please? It'll be more user friendly for the OP. Considering he's new to the Mac OS, i'm assuming he won't like fiddling around with applescripts/automator services –  XAleXOwnZX Aug 28 '12 at 6:32
    
@XAleXOwnZX Seeing as the file lives in ~/Library/Services I think describing a method to download the file then copy it here (as ~/Library is hidden by default on Lion), then follow half the MacYourself instructions to add the shortcut would actually be more complicated. The instructions provided by MacYourself are pretty straightforward to follow. –  binarybob Aug 28 '12 at 6:41
    
works i guess. Lol for these types of questions, i'd usually use package maker to create an installer that takes care of everything as needed, but i'm on vacation =/ –  XAleXOwnZX Aug 28 '12 at 6:42

If you need the path in Terminal/iTerm, you can just select the file/folder in Finder, copy it (Command-C), switch to the Terminal and paste it (Command-V).

You can also make a drag'n'drop the file/folder to the Terminal/iTerm.

share|improve this answer

Although this doesn't answer your question directly, I have a more efficient method of obtaining the file's path (presumably for it to be pasted into terminal or a text file, for example). Simply drag-and-dropping the file into a text field will automatically insert the file's path.

share|improve this answer

The easiest way I know to get the path to a file or folder is to Get Info on the folder or file (select it, right-click and pick Get Info), and then in the middle "General" section, you can select and copy (command + C) the path.

screenshot of file info with path

As for your other question, clicking on column headers in list view in the Finder does allow you to sort ascending or descending.

I do not understand the last question you ask -- again, I'd say go to the file itself, right-click and do as I described above to get the path.

share|improve this answer

Command + I, then copy information under Where:

enter image description here

share|improve this answer
    
@daviesgeek thank you so much for inserting an image for me. –  revolver Apr 3 '12 at 7:29
    
No problem. Glad I could help! –  daviesgeek Apr 3 '12 at 17:43
    
@daviesgeek Just want to know, how can I do the command button like you edited in my answer? –  revolver Apr 4 '12 at 2:00
    
You can use <kbd>Command</kbd> –  daviesgeek Apr 4 '12 at 4:49
1  
This is broken in Yosemite –  ClintM Nov 3 at 18:37

To copy the active path in Finder, simply control-click the folder or file to bring up the contextual menu. Next, select copy the_folder/file_you_want. Following that, you can paste the path to a terminal window.

share|improve this answer
    
Unfortunately this doesn't copy the whole path (name only). –  patrix Apr 2 '12 at 4:47
1  
edited. Doesn't copy the whole path everywhere, but does to a terminal window. If that's what the OP was looking for, then it works. –  soxman Apr 2 '12 at 5:33

Back a few years ago, I would always have the pos utility written by Gary Kerbaugh to improve finder / terminal interaction.

  • cdf would cd to the path of the frontmost Finder window
  • fdc would open a Finder window at the current shell path
  • posd would just dump the path

This coupled with pbcopy and pbpaste should fit the bill for getting arbitrary paths to text format and then into your clipboard.

I believe homebrew has adopted part but not all of this package so I'm not sure if you can find a workable version of all the above, but it was magic when I first started using it. Now I just use Launchbar to push files around without caring so much about recording a specific folder.

share|improve this answer
    
posd | pbcopy sounds like it would work. The rest seems nice to have (though won't open . work instead of fdc?) –  Kyle Cronin Apr 2 '12 at 4:35
    
It's unix - there should be n+1 other ways to accomplish most things even with n being sufficiently large. I like open . though - it's elegant. –  bmike Apr 2 '12 at 5:17

Next to the name of the folder in the Finder is an icon depicting that folder. This icon can be dragged to anywhere you need to accept a path - dragging to the Terminal or TextEdit in plain text mode will drop the path as text in the window or document. However, this does not work with all destinations - copying to a rich-text TextEdit document, for example, copies a link to the folder and not the path.

There are some third-party apps, some free, some paid, that add this functionality. You can also create a service with Automator (or AppleScript) to do it, but a simple and free method that I like, especially if you like to use the terminal anyway, is to invoke DTerm on the Finder window and run:

pwd | pbcopy

That will copy the current path to the Mac OS X clipboard.

share|improve this answer
    
Ooh - great use of DTerm. I never spent enough time to learn it's true power, but more people I know swear by it than at it. –  bmike Apr 2 '12 at 4:26
    
@bmike Yeah, I don't use it much, but it was my first thought when I read this question (after discovering that Finder indeed does not have this functionality built-in by default). It has the advantage that DTerm is a general-purpose tool and not something that needs to be installed or set up for this specific purpose. –  Kyle Cronin Apr 2 '12 at 4:36
2  
This is exactly what I use DTerm for most of the time! –  jtbandes Apr 2 '12 at 5:34

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.