Automator service to print a relative path of selected files printing everything twice I have a service that copy the selected file's paths and put them on the clipboard.

It kinda works, except everything gets printed twice.

The service is like this:  Get selected files from Finder > run script (as arguments) > copy to clipboard.

The script is:

for f in "$@"
do
   echo $f | cut -c 34-
done


I cut some starting characters because I need the path relative to some specific folder, and the size is always the same. I need this to submit the files I changed when committing files to a svn.

Here's an example, I selected three files, ran the service and this is the output:

layouts_index/f1/cadastro/confirmar.php
layouts_index/f2/cadastro/confirmar.php
cadastro/confirmar.php
layouts_index/f1/cadastro/confirmar.php
layouts_index/f2/cadastro/confirmar.php
cadastro/confirmar.php


Is this a problem in the script? Is there a way to fix it using the script or do I need applescript?

Thanks in advance.
Okay, think I got it. This is what I initially set up:



But when I ran that service, I only got a single list of files (which is what you want, but not what you were getting).

Footnote: when you’re having problems with an Automator workflow, a screenshot is really useful.

So then I decided to modify the "Service receives selected" field:



and if you try to run that from within Automator, then you get an error message:



When I go and run that service from outside Automator, I get the duplicated paths that you’re seeing.
So I think your list of selected items is getting picked up twice: once by "Service receives selected", and again by "Get Selected Finder Items".
When Automator goes to copy to the clipboard, it gets the list twice.

If you remove one of them, then you should get what you want.