Sometimes you need to copy the exact location of a file in macOS through all nested folders (in the graphical user interface of the Finder) or directories (in the identical Unix hierarchy accessible via Terminal). This can be useful for deleting a file that requires intervention through the Terminal or for troubleshooting. I recently had to dig up some errant Dropbox entries for their technical support to figure out why syncing would never complete.
There are two tricks to find this full path from the Finder:
- Control- or right-click a file or folder. After the contextual menu appears (and only after), add the Option key and then select Copy “file name or folder name” as Pathname.
- Open Applications > Utilities > Terminal. Drag the file into the Terminal. The path to the file or folder appears as a selection. In this method, the path name is escaped for Unix compatibility.
(Escaping means that any character that can’t be typed directly as part of a path in a Unix command has a backslash in front of it to “escape” it. This translates as, “Treat the following character as exactly what it is instead of something different that Unix would interpret as not part of the path.”)
In the first example above, the path would appear like:
/Users/glenn/Dropbox/Current Pubs/Macworld/Mac 911/Mac 911 July 2021/Mac 911 connect two Macs via WiFi.md
In the second in the Terminal (note the backslashes before every space):
/Users/glenn/Dropbox/Current\ Pubs/Macworld/Mac\ 911/Mac\ 911\ July\ 2021/Mac\ 911\ connect\ two\ Macs\ via\ WiFi.md
Ask Mac 911
We’ve compiled a list of the questions we get asked most frequently, along with answers and links to columns: read our super FAQ to see if your question is covered. If not, we’re always looking for new problems to solve! Email yours to email@example.com, including screen captures as appropriate and whether you want your full name used. Not every question will be answered, we don’t reply to email, and we cannot provide direct troubleshooting advice.