2

...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?

  • 3
    You never said how it failed. "It does not work" is pretty vague. – Allan Apr 28 '18 at 14:08
  • 1
    Thank you - the folder action just doesn't do anything. Nothing happens. The .m4a file gets dropped into the folder and no magic conversion happens. There's no error message or anything. – user6458800 Apr 29 '18 at 19:11
3

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
  • 2
    I think the path to ffmpeg is the key. It probably can't find it since it is not in the users path or environment. I have had similar problems with bash scripts on Automator. – ArchonOSX Apr 28 '18 at 16:06
  • 1
    Ok- so Terminal knows to look in the right place for ffmpeg (i.e., /usr/local/bin/ffmpeg) but Automator needs to be told? I'd used your suggestion and replaced the path with /usr/local/bin/ffmpeg but I only get the same symptoms (no response from the Folder and with the Application: 'ffmpeg: command not found'. – user6458800 Apr 29 '18 at 19:20
  • 1
    Yes, this answer and @ArchonOSX are correct. The shell that is opened is a non-interactive, non-login shell meaning it doesn't process the same files (.bash_profile and .bashrc) See this post for more explanation but suffice to say, if your path isn't set in both places or .bashrc doesn't source .bash_profile, it doesn't know about your path. – Allan May 1 '18 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .