Copy UNIX path to Finder selection

2009-08-13 03:04:23 -08:00

UPDATE 2009-08-14: Or just use CopyPath, which looks like a much better implementation of exactly the same thing. Thanks to David Keegan, its author, for suggesting it in the comments.

The original post content follows.


This is a script application, which apparently you can drag into your Finder toolbar. (If it doesn’t let you, you didn’t drop it in the right spot. Finder is finicky about this. Keep trying.)

Once you’ve added it to your toolbar, you can just click on it to run it. The script will copy the UNIX path of whatever you have selected in Finder to the clipboard.

Inspired by a conversation with Alan Boyd.

4 Responses to “Copy UNIX path to Finder selection”

  1. Jeff Johnson Says:

    Note that to some extent, this is already done automatically. For example, if you command-c a file in Finder and then command-v in Terminal, you get the unix path. You can see using “/Developer/Applications/Utilities/Built Examples/Clipboard Viewer.app” that the clipboard contains the unix path for a couple of pb types. Of course, it all depends on which app you’re pasting in; the unix path won’t get pasted in Safari or TextEdit.

    By the way, for another kind of Finder/Unix interaction, there’s an app called Open Terminal that you can also put in the Finder toolbar to open the selected or dragged folders in Terminal:

    http://homepage.mac.com/thomasw/OpenTerminal/

  2. David Keegan Says:

    http://inscopeapps.com/apps/copypath/
    http://bitbucket.org/keegan3d/copypath

    I’ve been working on an app for this that’s written in objective-c, so it does not popup in the dock, and has options for formating the paths into a python array, objective-c array, html image block or whatever you want.

  3. Zettt Says:

    Hi,
    I kind of like the idea of this script though it’s not working with multiple files.

    Here’s the same script for copying multiple UNIX path’s:

    tell application "Finder"
    	set fileList to {}
    	
    	-- get every selected Finder object and stack it on the end of fileList
    	repeat with i in (selection as list)
    		set the end of fileList to (POSIX path of (i as alias))
    	end repeat
    	
    	-- make fileList into a \r delimited list of strings
    	set AppleScript's text item delimiters to {return}
    	set flatlist to fileList as text
    	set AppleScript's text item delimiters to ""
    	
    	-- set the clipboards' contents to the flatlist
    	set the clipboard to flatlist as text
    end tell
  4. Zettt Says:

    Erm…that was not what I intended to do…the code or pre seem to screw my example.
    Make changes as you like to make this blog beautful again. ;)

Leave a Reply

Do not delete the second sentence.