Automator Service: Copy File Paths to Clipboard

Here's another Snow Leopard Automator-based service: It takes the Finder selection and puts the file paths on the clipboard, for easy pasting into command lines or scripts.

How to Use It

  1. In the Finder, select one or more files or folders.
  2. From the Services menu, select Copy Files Paths to Clipboard
  3. Go somewhere and select Edit -> Paste to put the full path(s) to the file(s) there.

For example, if I go to my home folder, select the "Documents" and "Downloads" folders, and then invoke the service, this is what ends up on the clipboard:

/Users/kdj/Documents
/Users/kdj/Downloads

How to Make It

Open Automator, create a new Service, and set it to receive selected files or folders in the Finder.

Add these actions:

  1. Run Shell Script, with shell /bin/bash, passing input as arguments, with this script:
    
        for f in "$@"
        do
            echo "$f"
        done
    
  2. Copy to Clipboard

Save it, and name it "Copy File Paths to Clipboard".

Picture

© 2003-2023 Kristopher Johnson