Automator help - passing filename to shell script

Hello all.
I am trying to do a simple automator service where if I select a file and right click and run the service that it grabs that filename location and passes it to a shell script to run. In this case it is mkvdts2ac3.

Right now I have a service called MKVDTS2AC3. In it I have "Get Selected Finder Items" then "Run Shell Script" with the following command ~/mkvdts2ac3/mkvdts2ac3.sh -n $@
I had read that $@ should grab the file location from the Get Selected FInder Items action, but it doesnt seem to be passing properly. I get an error when running the service.

Thanks!

MacBookPro Unibody, Mac OS X (10.6.2)

Posted on Jan 1, 2010 4:03 PM

Reply
4 replies

Jan 1, 2010 4:11 PM in response to Brian Critchlow

first, you do not need get selected finder items in an automator workflow saved a service. it already takes selected finder items as input provided you specify that at the top of the service. next, you need to check the option in 'run shell script' action to accept input as arguments. and its input is a list not a single finder item. so you either need to do this

for f in "$@"
do
~/mkvdts2ac3/mkvdts2ac3.sh -n "$f"
done


to process all items in the list or this

for f in "$@"
do
~/mkvdts2ac3/mkvdts2ac3.sh -n "$1"
done


to only process the first item in this list and discard the rest.

Message was edited by: V.K.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator help - passing filename to shell script

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.