Automator: Service to list File Paths of selected items, into Text File

automatorfinderpath

How can this Automator Service for Finder be created?

  • I'd like to be able to use Finder's Context menu (by right-clicking a Finder item) to run a Service that gets the file paths of the selected files.
  • The paths should be entered into a Text File (which can be unsaved or saved in the current folder).

Furthermore:

  • I currently only need to be able to get the paths of multiple selected files – but not the paths of subfolder contents, etc. I hope that serves not to overcomplicate things.

  • I would prefer if the filenames don't have Escaping Spaces ("Like\ This"), but instead normal spaces – but if there's a setting for that, I'd like how to alter between the modes within the script.

Best Answer

If you're looking for something that's more "pure Automator," here's one option (although, as was mentioned in the comments, right-clicking on the items in Finder, holding option, and selecting Copy Items as Pathnames is probably the easiest solution):

  • Accepts files or folders in Finder
  • Set Value of Variable Inputs
  • Run Shell Script: /usr/bin/dirname "$1" (make sure to pass input as arguments)
  • Set Value of Variable Parent Folder
  • Get Value of Variable Inputs <-- this should not accept input (right-click on the action and select Ignore Input)
  • New Text File (Plain text, [whatever file name you want], Parent Folder (drag this in from the variables list))

I've included a screenshot below:

Screenshot of Service