Quantcast
PC World: Technology Advice You Can Trust
Find a Review
Free Newsletters
Receive the latest reviews, how-to's, news, and more.
Product Tips & Reviews
Daily Downloads
Windows Vista
WiFi Finder
Locate wireless services by a specific address, city, state, country, airport, or zip code.
RSS Feeds
Get our latest content via convenient RSS feeds.
Latest News
Today @ PC World
Become a PCW Member
Join the community and start enjoying the benefits:
  • Get tech advice from thousands of PC World Members
  • Rate and recommend the latest tech products
  • Share your thoughts in blog and article comments
  • Get free excerpts and exclusive discounts on Super Guides
Read More About: Utilities

Copy Paths From Finder Selections

Rob Griffiths, Macworld.com

Friday, May 09, 2008 10:50 AM PDT
Recommend this story?

There may be times--such as when you're trying to convey to someone where a file can be found on their machine, or maybe when you're writing an OS X hints column--when you need to put the path to some file or folder into another document. In both OS X 10.4 and 10.5, it turns out there are many ways to do this. So short of just typing out the full path, what exactly are your options?

If you'd like to use a third-party solution, there are a number of contextual menu plug-ins available that add a "copy path to clipboard" feature to the Finder. Dan Frakes covered a couple of them in this Mac Gems entry. In addition, PathFinder offers path copying as a standard feature. This column, however, is all about doing things with what Apple provides, so here are some solutions that don't require any third-party tools.

First, you can use the Services menu. In both 10.4 and 10.5, the Services menu works in the Finder. With the object whose path you'd like to capture selected in the Finder, choose Finder -> Services -> TextEdit -> New Window from Selection. A new TextEdit window will appear containing the full path to the selected item. Press Command-A to select it all, then Command-C to place it on the clipboard.

Another option is dragging the object from the Finder and dropping it into a TextEdit window (or a Terminal window). This will only work if your TextEdit document is in plain text mode--if you use rich text mode and drag in something TextEdit can open, such as a JPEG image file, the file will be opened. But with TextEdit set to plain text mode, you'll instead see the path to the file or folder. Again, just select it and copy it to the clipboard, and you're done. (Some third-party text editors support this feature as well; it works with Smultron on my machine, for instance.)

You can also copy any item (file or folder) in the Finder and paste it into Terminal. You'll see the path on the command line; you can then select it with the mouse and copy it. You can also press Command-Space, then drag-and-drop the file into the Spotlight search box. Finally, you can drag a Finder window's proxy icon--the small icon in the title bar of the window--into TextEdit (again, in plain text mode) to see the path to that folder. Select the path and copy it to your clipboard.

But what about one-step solutions? Is there any one-step method of getting the currently-selected item's path from the Finder to the clipboard? While not quite a built-in solution, you can write a very simple AppleScript that will do this for you. Open Script Editor and enter these four lines:

Select File -> Save to bring up the Save dialog. Give your program a name (Get Path), save it somewhere safe (your user's Documents folder), and set the File Format pop-up to Application, then click Save. Now navigate to the spot where you saved your four-line program, and drag it to the Dock or to a Finder's sidebar or toolbar area. When you need the path to an item, first select that item, then click on your program's Dock, sidebar, or toolbar icon. You'll briefly see your program load into the dock, then quit. When it quits, switch to your target application and press Command-V to paste the path.

If you prefer, you can also easily make this AppleScript a Finder contextual menu plug-in. Launch Automator, create a blank workflow, and then drag the Automator -> Run AppleScript (Utilities -> Run AppleScript in 10.5) action to the work area. Replace the stock AppleScript text with the three-line script you see above, then choose File -> Save as Plug-in. In the new window that appears, give your plug-in a name (Copy Path to Clipboard), set the Plug-in For pop-up to Finder, and click Save. Switch back to the Finder, select something, Control-click on it, then select your new workflow from the list. Wait a second (watch the menu bar to see when the workflow has finished) and then switch to your target application and press Command-V.

I'm sure there are more ways to do this; these are just a few of the easier solutions; use whichever you prefer, obviously, including the third-party solutions that Dan covered in his write-up.


Macworld
For more Macintosh computing news, visit Macworld. Story copyright © 2007 Mac Publishing LLC. All rights reserved.


Recommend this story?

Comments
Tags at a Glance
Latest News
The iPhone's reach expanded again Friday, with Orange announcing plans to sell the phone in Europe, the Middle East and... 16-May-2008
A new train simulator codeveloped by Fujitsu offers unparalleled realism thanks to high-definition video shot on actual train... 16-May-2008
Samsung Electronics will unveil this weekend the first prototype of a new LCD (liquid crystal display) technology that won't... 16-May-2008
With all the time spent on the road, most drivers consider their cars to be their second homes. Reaching their primary home... 16-May-2008
Internet users in China have begun expressing solidarity with the victims of Monday's earthquake via their instant messaging... 15-May-2008
Sony has promoted a senior executive at its U.S. games studio to lead its global studios, it said Friday. 15-May-2008
Fujitsu has developed a prototype electronic paper screen that tackles one of the technology's biggest weaknesses: the amount... 15-May-2008
The One Laptop Per Child Project and Microsoft plan to make both Windows and Linux available on a version of the project's XO... 15-May-2008
Yahoo has responded to investor Carl Icahn's threat to take control of Yahoo's board and force it back to the negotiating... 15-May-2008
Billionaire investor Carl Icahn's proxy fight for Yahoo is aimed at reigniting merger talks between the Internet company and... 15-May-2008

PC World's Marketplace

PC World's Free Whitepapers

Name City
Address 1 State Zip
Address 2 E-mail (optional)