This is a handy trick that I use from time to time. Say you’ve selected a file or folder in a Finder window, and you want to copy the full path to that file or folder as a text string – for pasting into an email or a script, for example. Here’s how:
- Open a Terminal window.
- Drag the file or folder to the Terminal window. (The full path appears in the window.)
- Select the path in the Terminal window, copy it, and paste it into your email or script.
- Close the Terminal window.
The only slight snag is that, if your file or folder path contains spaces, the spaces get escaped with ‘\’s in the Terminal window.
If the escaped spaces bug you, or you often want to copy the path to a file, check out the catchily-titled FilePathToClipCMPlugin. Download and open the .dmg, drag the FilePathToClipCMPlugin.plugin file to ~/Library/Contextual Menu Items, and restart the Finder (Apple menu > Force Quit, then choose Finder in the list and click Relaunch). You can now right-click any file or folder and choose FilePathToClip! to copy it to the Clipboard. Works a treat.
(PathSnagger does a similar thing, but sadly it doesn’t have a stable Universal Binary version yet so I can’t test it.)