39

I have a text file opened up in TextEdit, and I can't seem to figure out the full path of the file.

Also, if I search for the file in spotlight, it doesn't seem to tell me the full path of the file either.

I'm clearly missing something here. How to tell the full path?

1
  • Are you on lion? Otherwise, the save-as feature should take you to the correct directory.
    – soandos
    Dec 25, 2011 at 17:49

7 Answers 7

48

You can Command-Click the icon and file name in a window's title bar to reveal the full path as a menu:

enter image description here


You almost never need this path: Due to the lack of an address bar in Finder, where would you paste it? You can just drag the file proxy (the icon) from a window's title bar into an Open… file dialog to select it e.g. in a different application.


If you really want the full path to a file in a copyable form, you can drag and drop the file or its proxy icon onto a Terminal window. From there, you can then copy and paste it.

enter image description here

Simple text editing fields (like text areas on web sites), or Text Edit's plain text view behave in a similar way: Just drag & drop the file onto them.

enter image description here


You can also use Automator to create a Service that copies a selected file or folder's path to the clipboard. Launch Automator, select Service, and that it receives selected files and folders in any application. Save, and name it e.g. Copy File or Folder path.

enter image description here

Just select a file or folder in Finder or any other program that works in a similar way and invoke your new service from the Application Menu » Services » Copy File or Folder path (it will only show up if you actually have files or folders selected). You can assign a keyboard shortcut in System Preferences » Keyboard » Keyboard Shortcuts » Services


A file's path is also displayed in its details dialog in the General category, from where it can be selected and copied:

enter image description here


A selected file's path is also displayed in the Finder's path bar, which you can enable from View » Show Path Bar. It's enabled by default for Spotlight results windows AFAIK.

enter image description here


From the Spotlight menu, you can press Command-I to open the file's Get Info dialog, drag it to Terminal, drag it to a TextEdit plain text view or a similarly simple view, or drag it to an Open… file dialog.

From the Spotlight results window, you can open the Get Info dialog, drag the file to Terminal, to TextEdit, an Open… file dialog, or invoke the service. The full path is also displayed in the Path Bar.

4
  • 1
    Sadly Sierra has broken the Get Info window paths by trying to make them prettier with little arrows instead of slashes - for some mad reason. While they do magically turn back to slashes when copy/pasted - they forgot to escape spaces, so most paths are broken.
    – scipilot
    Aug 19, 2017 at 7:35
  • 1
    @scipilot It's impossible for Apple to know where a path might be used. Could as well be in a Go to Folder… dialog which won't handle "escaped spaces", as there's no need for escaping there. That's why there's Paste Escaped Text in Terminal – to add it when you know it's needed.
    – Daniel Beck
    Aug 19, 2017 at 21:52
  • You're absolutely right, non-escaped is correct and I wasn't considering the variety of uses. If I didn't use bash for almost everything, I'd be complaining even more if it was pre-escaped! Thanks for the tip - I'd never noticed all those extra edit commands.
    – scipilot
    Aug 20, 2017 at 4:19
  • This is superuser, the statement "you will almost never need this path" is definitely not true if you're referring to the file's absolute path. Might be true for an average user, but not a superuser. There are countless reasons why someone would want an abspath aside from "to copy-paste them into a non-existent address bar" Feb 7 at 15:24
3

You can show full paths in the Spotlight menu by holding command and option. Or in Alfred ⌘C copies the absolute paths of files.

I have assigned this script to ⌃⌘C:

try
    tell application (path to frontmost application as text)
        set the clipboard to (path of document 1) as text
    end tell
on error
    try
        tell application "System Events" to tell (process 1 where frontmost is true)
            value of attribute "AXDocument" of window 1
        end tell
        do shell script "ruby -rcgi -e 'print CGI.unescape ARGV[0][16..-1]' " & quoted form of result
        set the clipboard to result
    end try
end try

The first method didn't work with Preview, TextMate 2, Sublime Text, or iChm, and the second method didn't work with Acorn.

2
  • Just curious, where do you use these paths?
    – Daniel Beck
    Feb 2, 2013 at 13:40
  • 1
    @DanielBeck I don't ever drag proxy icons anywhere—I hate the way dragging from one window to another just takes so much time (especially if you have to wait for them to receive focus, or when they overlap and you have to move them away before, etc.). Also, I usually do this to edit scripts somewhere, and run them from a command line with their absolute path.
    – slhck
    Feb 2, 2013 at 17:44
1

In most programs you can command+click (or apple+click, depending on your keyboard) on the file's name in the title bar of its window and you'll get its path arranged vertically in a dropdown list.

Or in Finder, for instance after a search, you can select the file and do command+I to bring up the file information window, which should have the full path somewhere.

3
  • Option-click has never worked for this on my machine. Did you mean Command-click?
    – Daniel Beck
    Dec 25, 2011 at 18:52
  • You're right. It's command+click instead of option+click. I'm fixing that right now. Option+click doesn't do anything much I was thinking of option-drag, which lets you drag the icon from the title bar to a different folder, or disk or the trash without needing to open up a finder window to the file's current location. But I see you've covered that and more in your own answer. Dec 25, 2011 at 20:50
  • You don't actually need to press Option for that. You just need to press the mouse button for a moment before moving the pointer away from the proxy icon, then you can drag. Option then makes it a copy operation instead of destination-dependent copy, move or alias.
    – Daniel Beck
    Dec 25, 2011 at 21:00
0

If you use Preview, the full path of the current opened file can be revealed by right click the file name on the title bar.

0

If you have the file opened in the Preview app or in TextEdit, you can right-click the file name in the title bar. This will reveal the full file path.

If you want to open that path, just select the folder you want to open.

0

Use the command "locate" from the terminal. It will tell you the path to the file https://linux.die.net/man/1/which

locate foobar

It is a database of all files, the database only updates once a day but you can force the command with

updatedb

enter image description here

0

For use in a terminal / script setting it's best to install the GNU coreutils using Homebrew (see https://formulae.brew.sh/formula/coreutils ) , and use the realpath utility. It does all symlink resolutions and doesn't need the locate database, i.e. it's always up to date.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jun 8, 2023 at 10:09

You must log in to answer this question.

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