I am passing arguments (selected finder items) in Automator, to a shell script (Sox script to convert wav files to u-law wav files). I have two problems:
If there are more than 10 items selected, the shell script ignores anything past the first 10 arguments, and also, as the script stands right now, even when passing lessing than 10 arguments (finder items) the shell script will act on all but the last selected item. So, if I select 3 files in automator, the first 2 will get through, not the third. Or if I select 4 files, 3 files will make it through - and so on.
Here is my Automator Action order
Ask for Finder items
Set Value of Variable
labelled variable "input-files"
Get Value of Variable
get variable "input-files"
Run Shell Script
#! /bin/sh
soxloc="/usr/local/bin/sox";
tempfile="";
shopt -s nullglob
for f in "${@:1}"/*.wav
do
"$soxloc" "$f" -r 8000 -c 1 -e u-law "${f%.*}"-ulaw.wav
done
There are a few solutions listed on SO including the below link, but I'm just not sure how to integrate any of these solutions into my code:
How to handle more than 10 parameters in shell
Any help would be greatly appreciated!