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
Microsoft on Tuesday announced it would restore support for Visual Basic for Applications (VBA) to Microsoft Office for Mac, a... 13-May-2008
Nearly two years ago, Microsoft announced that it was removing Visual Basic for Applications (VBA) from Office 2008 for Mac. A... 13-May-2008
Although the actual Digital Negative (DNG) raw camera plug-in for Photoshop remains at 4.4.1, Adobe on Tuesday offered up... 13-May-2008
Computer Sciences (CSC) has agreed to pay US $1.37 million to settle allegations that it received kickbacks on technology... 13-May-2008
HBO will begin selling some of its most popular television series on Apple's iTunes Store, the companies announced on Tuesday... 13-May-2008
A variety of malware already infects millions of PCs in an accelerated attack, security expert warns. 13-May-2008
The European Commission confirmed it has received a complaint about Microsoft's business practices from a British government... 13-May-2008
On Tuesday, Microsoft released Service Pack 1 (SP1) for Office 2008 for Mac, designed to add stability, security, and... 13-May-2008
HP's acquisition of another top-tier IT company brings benefits but huge challenges, analysts agree. 13-May-2008
Some episodes could cost $1.99 and up, in a pricing switch, sources say. 13-May-2008

PC World's Marketplace

PC World's Free Whitepapers

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