Automator fail with ffmpeg bash line

automatorbash

…achieves this, but I'll like use set up an Automator Folder Action to do this for me.

AFAIK, the automator in this screen shot should work but does not.

I'd read some stuff – which I didn't really understand – about "$f" needing to be in quotes, but it already is.

enter image description here

Any advice, please?

Best Answer

Automator supplies arguments (file names) to the shell script. Try:

for f in "$@"
do
    case $f in
        *.m4a)
             /absolute/path/to/ffmpeg -i "$f" -acodec libmp3lame -ab 256k "${f%.m4a}.mp3"
             ;;
    esac
done