Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

harleytat

macrumors newbie
Original poster
Jul 22, 2002
23
4
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:

Code:
/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.)
 
Last edited:
Code:
/usr/local/bin/lame --preset insane "$@" "$(echo $@ | 'sed s/\.[^.]*$/.mp3/')"
 
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:

Code:
/usr/local/bin/lame --preset insane "$@" "$(echo $@ | sed 's/\.[^.]*$/.mp3/')"
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.