Bash script using Lame to convert WAV files to MP3 recursively in sub directories.

Feb 6, 2017 | Linux, Music, Scripting and programming, Technology | 0 comments

I wrote this as the lazy way out because I didn’t want to bring a lot of WAV files back to a local box. I know everything is in artist/album format with plenty of spaces in the file names so this type of thing works perfectly for me.
Of course, you need lame installed.
I hope this helps.

LAMEOPTS="-b 192"
for DIRECTORY in /music/*/*; do
if [ -d "$DIRECTORY" ]; then
echo "$DIRECTORY";
for FILE in "$DIRECTORY"/*.wav ; do
OUTNAME=basename "$FILE" .wav.mp3;
echo "$FILE" "$DIRECTORY"/"$OUTNAME";
lame $LAMEOPTS "$FILE" "$DIRECTORY"/"$OUTNAME";
rm "$FILE";
done
fi
done

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.