I’ve ripped a bunch of my CDs onto my computer over the years and many of them ore in the open OGG format which doesn’t work with my iPod or Treo. I wrote a simple little script to convert the OGG files to MP3 for my phone. Since Real Player on my phone only seems to support a flat directory structure, I created the file names out of artist and song name. I just mount up the SD card, change directory to it and run the script passing the songs I want to copy on the command like. Using wild cards makes it easy. For example:
cd /media/sdcard ; ogg2mp3 /home/terry/jukebox/Yeah_Yeah_Yeahs/Show_Your_Bones/*
The script looks like this…
USAGE=false
if [ ! -f "$1" ]
then
echo "Usage $0 sourceFiles ..."
exit 1
fi TMPFILE=/tmp/tmp$$.wav
while [ $# -gt 0 ]
do
ogg123 -d wav -f $TMPFILE "$1"
DIRNAME=`dirname "$1"`
ALBUM=`basename $DIRNAME`
TMP=`dirname $DIRNAME`
ARTIST=`basename $TMP`
MP3FILE=`basename "$1" | sed -e 's/.ogg/.mp3/' | sed -e 's/^[0-9][0-9] - //'`
OUTFILE="${ARTIST}_${MP3FILE}"
echo "-------------$OUTFILE"
lame $TMPFILE "$OUTFILE"
shift
done
rm -f $TMPFILE