I find myself needing the path to a file relatively frequently to add to an email or documentation. I added a service to the Finder contextual menu to get the path to the selected item. This service notifies me with an alert (just for fun) and can be invoked with a keyboard shortcut. This was done in Mavericks (10.9). Most of it should work in 10.8 or 10.7 (except the notification).
To start, open Automator (/Applications/Automator.app) and choose to make a New Document. When prompted, select to create a Service and click Choose.
This will create a new workflow that takes the selected items as input. Change the “Service receives selected” menu to say “Files or Folders” and change “any application” to be “Finder”.
Then we need to add the appropriate actions.
First we need to get the actual path to the selected item. There isn’t an action to do this exactly, so add the Run AppleScript action. Replace “(* Your script goes here *)” with:
tell application "Finder" return POSIX path of input end tell
Then add a Set Variable action and name the variable “myPath”.
Add the Copy to Clipboard action. Then add the Display Notification. Enter a Title, like “Path Copied” and for the Message, drag in the myPath variable and add ” is on the clipboard”.
It should look like this:
Now save this as Copy Path (~/Library/Services/Copy Path.workflow) and try it out in the Finder.
You should see an alert
and then be able to paste the path into a text field somewhere. If you don’t want the alert, then your service only needs the applescript and copy to the clipboard actions.
To add a keyboard shortcut, open System Preferences. Select the Keyboard panel and the Shortcuts tab. Select App Shortcuts and click the plus sign.
Set the shortcut to only work in the Finder, enter the title exactly, and put in a keyboard combo to use.