Copying file paths

A common request I see from readers, both via email and in the Macworld forums , is for a way to copy the path of a file—for example, /System/Library/CoreServices/Menu Extras/Script Menu.menu —to the Clipboard. Perhaps you’re trying to explain to someone, via email, exactly where a particular file is, or maybe you want to use that file path in Terminal.

You can view the path to the current folder by using the Finder’s Customize Toolbar command (under the View menu) to add the Path item to Finder toolbars. Clicking on this toolbar item displays the path to the current folder. (You can view a similar path display by Command-clicking the proxy icon at the top of any Finder window.) Unfortunately, you can’t copy this path.

A solution to this dilemma can be found in contextual menu plugins. Installed in ~/Library/Contextual Menu Items (for use only in your own account) or in /Library/Contextual Menu Items (for use by all accounts on your Mac), such plugins add new options to your contextual menus—the menus that appear when you right-click or Control-click on an item in the Finder. (Some plugins also provide additional options to the contextual menus available within applications.)

The sheer number of contextual menu plugins out there that let you copy a file’s path is a good indication of the popularity of this feature; here are a few of my favorites.

If you’re already using Gideon Softwork’s FileXaminer (   ; $10)—a comprehensive file utility and one of our all-time favorite Gems —it provides just such a plug-in. FileXaminer offers to install this plugin the first time you launch the application; otherwise, you can install it via a button in FileXaminer’s preferences. The next time you log in, the Finder’s contextual menus will feature a new Copy Path item.

FileXaminer Copy Path

Also handy are FileXaminer’s optional keyboard shortcuts, one of which lets you copy a file’s path by selecting the file in the Finder and then pressing Command+Option+C. Unfortunately, one limitation of FileXaminer is that it can’t copy the path of an item with certain special characters, such as ™, in its name (or anywhere in the path, for that matter).

If you don’t have FileXaminer and you’re looking for a simpler solution, Limit Point Software’s FilePathCM 1.0.3 (   ; payment requested) is a standalone contextual menu plugin that offers just the basic, contextual-menu path-copying feature. Unfortunately, rathing than placing its Copy Path command in the main contextual menu, FilePathCM adds submenu, requiring you to choose FilePath:Copy Path. On the other hand, FilePathCM is able to copy paths that contain special characters.

FilePath CM

Finally, if you’ve got a PowerPC-based Mac, another good option is Bergen Street Software's PathSnagger 1.1b5 (   ; payment requested), which offers the ability to copy file paths in either Unix format ( /System/Library/CoreServices/Menu Extras/Script Menu.menu ) or HFS format ( System:Library:CoreServices:Menu Extras:Script Menu.menu ). It also offers a handy System Preferences pane that lets you customize its contextual-menu options. (PathSnagger’s contextual menu plugin may actually work on Intel Macs; however, its PowerPC preference pane won’t. The developer has an “experimental” Universal binary version available, but warns that it’s not finished or stable.)

PathSnagger preference pane

FileXaminer 2.6.1 requires Mac OS X 10.2 or higher; FilePathCM 1.0.3 requires Mac OS X 10.3.9 or higher. Both are Universal binaries. PathSnagger works on PowerPC Macs running Mac OS X 10.1 or later.

Want to stay up to date with the latest Gems? Sign up for the Mac Gems newsletter for a weekly email summary of Gems reviews sent directly to your Inbox.

Subscribe to the Help Desk Newsletter

Comments