Converting Full Directory Mp3 with Lame via Shell Script

Published on September 21, 2008 by Hallaj under Scripting

I got bored earlier and was searching for Saturnine (it’s an old band from Malaysia) and I’ve managed to get a link to download their mp3. However, the quality was a bit bad so I decided to convert it manually using Lame. I didn’t download the GUI version and to convert a lot of files it would be troublesome to type the whole filename, path and so on, I’ve decided to write a custom shell script for this. Anyway, you can modify it as you see fit. Cheers :)

#!/bin/bash
 
# Input Mp3 Path
mp3Source="/path/to/my/original/mp3/"
# Output Mp3 Path
mp3Output="/path/to/my/output/mp3/"
 
for i in "$mp3Source"*.mp3; do
        myName=`echo $i | sed "s#$mp3Source##"`
        /usr/bin/lame --resample 44.1 -b 192 "$i" "$mp3Output$myName"
done

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>