How to copy Unix file path in OS X Yosemite

When I try to get the path of a file using ⌘ (Command)+I, it gives the path in a different way.

I see this only after updating to Yosemite. It is not a text. How do I get it in the format /Users/Myself/Documents/…?

Answer

Just select the file itself in Finder and press CmdC or go to Edit » Copy. You can then paste the path directly to a terminal window.

Note that this will escape special characters.

If you want the path in human-readable form, you need to do the following:

  • Open Utilities/Automator.app
  • Create a new Service
  • Set it to receive no input from Finder.app
  • Drag Run AppleScript from the left pane to the right
  • Paste the following into the field:

    tell application "Finder"
        set sel to the selection as text
        set the clipboard to POSIX path of sel
    end tell
    
  • It should look like this:

  • Save the service under any name you like, e.g. Copy human-readable path.

This is part one. Now, set a keyboard shortcut:

  • Head to  » System Preferences » Keyboard » Shortcuts
  • Go to the Services section and scroll down
  • Set a keyboard shortcut for your service

Et voilà, now press that shorcut when you need the path of any selected Finder item.

Attribution
Source : Link , Question Author : Madusanka , Answer Author : slhck

Leave a Comment