Perhaps it is not necessary for another article about how to convert cd’s to a format that can be used on our mp3 or ogg music players. I have used k3b program for extracting ogg files in the past.
I suspect that there are also a number of similar programs on the windows side that are just as easy to use. I would have used this method but I had a small stack of disc’s that needed to be ripped and I would prefer to just kick off a command line to do the task.
There already exists a fabulous script called “abcde” for doing most of this work. This script extracts the audio data as wav data and then uses the desired codec for converting this wav data into the new format (ie mp3 or ogg).
The abcde script also downloads the names of the songs as well as the album art (for abcde version 2.7 and higher).
I knocked together the following script which will extract either ogg or mp3 files and rename the temporary directory into the name of the album. By default, this script will call abcde and convert the ripped files to ogg format. If this script is called with mp3 it will then rip the files and convert them to mp3.
FORMAT=ogg if [ $# -eq 1 ] then FORMAT=$1 fi TMPDIR=abcde.`cd-discid | sed 's/ .*//'` abcde -N -g -d /dev/sr0 -a read,encode,tag,getalbumart,clean -o $FORMAT -x cd $TMPDIR CNT=$((`cat cddbchoices | wc -l` - 2)) IDX=1 while [ $CNT -gt 1 ] do TRACK=`tail -$CNT cddbchoices | head -1` TRACK=`echo $TRACK | sed 's/^..: //'` TRACK=`echo $TRACK | sed 's/^.: //'` TRACK=`echo $TRACK | sed 's/ /_/g' | sed 's/[^a-zA-Z0-9_-]//g'` FILENAME=$IDX if [ $IDX -lt 10 ] then FILENAME=0$IDX fi DEST_FILENAME="$FILENAME - $TRACK.$FORMAT" SRC_FILENAME=track${IDX}.$FORMAT if [ -f $SRC_FILENAME ] then echo mv "$SRC_FILENAME" "$DEST_FILENAME" mv "$SRC_FILENAME" "$DEST_FILENAME" fi CNT=$(($CNT - 1)) IDX=$(($IDX + 1)) CNT=1 done ALBUM=`head -2 cddbchoices | tail -1 | sed 's/ /_/g' | sed 's/[^a-zA-Z0-9_]//g'` ALBUM=`echo $ALBUM | sed 's/^_//g'` ALBUM=`echo $ALBUM | sed 's/_$//g'` cd .. mv $TMPDIR $ALBUM echo $ALBUM
To be honest all of this scripting should be unnecessary. Logic exists for doing all of this for you. Simply change the configuration file to select the output format.
The standard configuration file /etc/abcde.conf allows for a lot of individual configuration. Simply uncomment the OUTPUTFORMAT variable and change it to fit your needs.
#OUTPUTFORMAT='${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
For reasons unknown, this didn’t work for me. Nor did creating a configuration file .abcde.conf in my home directory.
There is a lot information on the internet about how to use or configure and use this utility.
http://www.andrews-corner.org/linux/abcde/index.html
https://www.mankier.com/1/abcde
One of the more interesting things about the abcde script is that you can create multiple output files at the same time. It is possible to create both mp3 and ogg files at the same time. If both types of files are required then this is actually the fastest way to convert into both types of data.
Simply create a list of all formats when running the script.
-o mpg,ogg
Note: After writing this small script I discovered it didn’t work. Well, it worked just fine for CD’s that only had one IMDB entry. Even not using my script, the abcde script is fabulously useful.