macOS: How to Copy Files as Pathnames

I spend a lot of my time sending out emails with instructions on how to do stuff. Tons of my time. An astonishing amount. Sheesh, you’d almost think helping people with technology was, like, my job or something.

Because of that, I’m always looking for ways to make sending instructions more efficient, whether it’s by using boilerplate text replacements, for example, or memorizing handy keyboard shortcuts. One of my favorite tricks came about with El Capitan, and that’s the ability to copy files or folders as pathnames in Finder. I use this so often these days that it’s become integral to my workflow!

As an example, let’s pretend that you wanted to point someone to this file:

/System/Library/WidgetResources/AppleClasses/Images/[email protected]

Ignoring the fact that no one in the history of ever has needed to reference that file, look at how long the path is! If you were to type that out, being sure to get all of the capitalization and so on correct, it’d take a while. The easier way to go is to use a shortcut, so first, select the file or folder you want to copy the pathname for…

macOS Finder Window showing the path to a file

…and then press the shortcut Option-Command-C, which is short for Finder’s Edit > Copy as Pathname menu item.

Copy as Pathname in the Finder's Edit menu puts the path to the currently selected file in the Clipboard

If you plan on using the Edit menu for this rather than the shortcut, know that you have to hold down Option in order for “Copy as Pathname” to appear.

Finally, go to wherever you’d like to put in the path, which could be an email, a message, or heck, even the Terminal, and just press Command-V to paste it as you normally would. Your Mac will make it look all nice and everything, just like my example above, and you can revel in the fact that you know how to do something pretty cool. I recommend reveling in that, actually.

6 thoughts on “macOS: How to Copy Files as Pathnames

  • Thanks for the comments, guys!

    And vpndev, I appreciate you pointing that out. I should’ve noted that in Terminal, using Control-Command-V will paste the escaped text properly, which would certainly help if you’d copied a pathname with spaces. 🙂

  • Thanks for the tip; and also a perfect example how the UI has in some ways deteriorated over time. I’ve used contextual menus forever but had not noticed that command since it is not readily discoverable. Even today, I forget to do the little Option Key trick with menu selections etc., thus there is no telling how many cool time savers might exist. My bad. But Apple’s too.

  • Brilliant.

    I have the full-POSIX-pathnames thing set and have often tried to get the command-click thing to get the pathname, but to no avail. That would be especially nice since it would work for docs open in an application, and not just in Finder.

    But I must mention one caveat with regard to Terminal …
    >Finally, go to wherever you’d like to put in the path, which could be an email, a message,
    >or heck, even the Terminal, and just press Command-V to paste it as you normally would.

    The pathname is just the pathname and might contain spaces. If folks use this name string in Terminal and it contains spaces then it must be wrapped in quotes. That is, type the command, then a double-quote (“), paste the pathname, add a closing double-quote, and press return/enter.

    This is because spaces are delimiters in bash-land.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.