More copying file paths
Last week I covered a number of ways to copy the path to a file in the current Finder window; for example, for pasting in an email or document, or for use in Terminal. Specifically, I recommended three contextual-menu plugins. The response to that article was surprising; evidently this is a feature more than a few people find useful. However, discussion in the Macworld forums , along with numerous emails I received from readers, illustrate that the old adage, “different strokes for different folks,” holds true even for something as simple as copying a file path.
Reader WJW asked why you wouldn’t just create an AppleScript applet that copies the path of a file, and then place that applet in the Dock where you could drag any file onto it. Similarly, reader Mike LaMorte let me know about an AppleScript, getpath , he created and posted on his Web site as a free download. As Mike explained, “The script will copy the path of the selected item to the clipboard, sans any forward-slashes before spaces and other control characters.” After selecting a file or folder in the Finder, you can run the script from Mac OS X’s script menu (simply place it in /Library/Scripts or ~/Library/Scripts to make it available). Here’s Mike’s script, which is just one of a number I received via email:
set itemPath to "" set uPath to "" tell application "Finder" activate set itemPath to selection as string set uPath to POSIX path of itemPath set the clipboard to uPath end tell
Alternatively, you can create an Automator workflow that includes such a script: paste the above code into an Automator “Run AppleScript” action, and then save the workflow as a Finder plug-in; this makes the script available in the Automator sub-menu of the Finder’s contextual menus.
Both these approaches work, and I applaud anyone who uses AppleScript and Automator—two technologies that don’t get enough credit, in my opinion. That said, I still like the contextual-menu approach (and I don’t like Automator’s requirement that Finder plug-ins be hidden in the Automator sub-menu); for me, it’s just quicker and more convenient. Some of you agree and suggested a couple additional options, both free.
Abracode’s FileUtilsCM 1.7.2 ( ) is a contextual-menu plugin that provides a number of options for working with file attributes in the Finder; one of these options lets you copy the path to the current file. Because it has so many features, FileUtilsCM places its options in two submenus, one listing actions it can perform and another showing detailed information about the selected Finder item. (Unfortunately, the latter won’t display the total size of folders or volumes; only of individual files.)
A useful feature of FileUtilsCM is that it includes a configuration utility that lets you choose which of these options appear in contextual menus, as well as what format—URL, Unix, Mac, or Windows—is used when an item’s path is copied to the Clipboard.
Hsoi’s Shop’s free CMPlugins 2.1 ( ) package also offers a number of contextual-menu functions, but provides them via individual plugins; you install just those plug-ins you want. I include CMPlugins here because one of the options is FilePathToClipCMPlugin, which copies to the Clipboard the path to the selected file (using the / character as the delimiter; for example, /Users/frakes/Desktop/document.doc ). But the package also includes plugins for using the selected image file as your Desktop background (this feature works only for the main display); copying to the Clipboard a hierarchical listing of the contents of a selected folder; locking and unlocking files; and, for developers, toggling the modified-read-only flag of a file’s ckid resource.
Both FileUtilsCM and CMPlugins’ FilePathToClipCMPlugin are able to copy file paths that include special characters such as ™ (as mentioned last week, some utilities have problems with these characters).
And with that, hopefully I’ve given you more than enough ways to copy a file’s path to the Clipboard.
FileUtilsCM 1.7.2 requires Mac OS X 10.3.9 or higher; CMPlugins 2.1 requires Mac OS X 10.4 or higher. Both are Universal binaries.