LAME/Automator/shell script question

Discussion in 'Mac Programming' started by harleytat, Nov 9, 2011.

  1. harleytat, Nov 9, 2011
    Last edited: Nov 9, 2011

    harleytat macrumors newbie

    Jul 22, 2002
    I'm writing a simple Automator script to convert WAV and AIF files to MP3 using the LAME encoder.

    After passing the file, I run this shell script:

    /usr/local/bin/lame --preset insane $@ $(echo $@ | 'sed s/\.[^.]*$/.mp3/')
    The whole part after "echo" effectively replaces the previous file extention with ".mp3". Works great, except it can't handle files or folder paths with spaces. I assume this is a quick fix involving quotes of some kind—any help is much appreciated.

    (BTW, if there's an easier method of replacing file extensions, I'm all for it.)
  2. sero macrumors member

    Aug 28, 2008
    /usr/local/bin/lame --preset insane "$@" "$(echo $@ | 'sed s/\.[^.]*$/.mp3/')"
  3. harleytat thread starter macrumors newbie

    Jul 22, 2002
    Brilliant—thank you. I swear I thought I'd tried every combo of double quotes.

    Also, there was a type in my original command, so here's the real deal:

    /usr/local/bin/lame --preset insane "$@" "$(echo $@ | sed 's/\.[^.]*$/.mp3/')"

Share This Page