This is an interactive bash script to rip and encode audio tracks, based on both cdda2wav and Lame (http://lame.sourceforge.net).
I wrote it because I needed to rip a Jazz CD ; and as I had not enough hard disk space, it wasn't a good idea to use grip; since it deletes the WAV source only after finishing job, which results some GB are (temporary) accumulated on the hard disk. Features:
Tags album, artist, track name (a bit boring ), bitrate and generates a filename from the track name compatible with Linux; if file exists it will generate a random MD5 hash ...
Removes the WAV source once encoding file is finished.
Tests:
Like NT : Never tested . Well, just one time, to rip my CD and it was successful. I don't have enough disk space to test more.
Bug:
May have too many, but I'd like to know which command displays the number of tracks in an audio CD.
Source:
#!/bin/sh
#You should have cdda2wav and Lame
CDDA2WAV_PATH=/usr/bin/cdda2wav
LAME_PATH=/usr/local/bin/lame
AUDIO_DEVICE=/dev/hdc #Well, it's my PC
if [ -e $CDDA2WAV_PATH ] && [ -e $LAME_PATH ] #If files exist ...
then
echo "Files seem to exist; let's proceed..."
else
echo "Please check out whether lame (lame.sourceforge.net) and cdda2wav are correctly installed, and the paths are exactly set"
exit 0
fi
echo "Please type the album name:"
read albumname
echo "Are these music files to the same artist? (y/n)"
read ans
case $ans in
y*|Y*)
echo "So would you type his/her name?"
read artistname
;;
n*|N*)
sep=1
;;
*)
echo -e "\e[35mAnswer should be \"y\" or \"n\" ; Reseting...\e[39m"
sleep 1
echo ""
$0
;;
esac
echo "Number of tracks to rip" #I'm facing a problem: I don't know how to get the number of tracks from an Audio CD ; that's why it's to you to fill out it
read num
if (echo $num|grep [[:alpha:]] >/dev/null)
then
echo -e "\e[36m$num doesn't seem to be a number. Exiting\e[39m" #Don't cheat, or you go to the /dev/null (The Hell)
exit 0
fi
echo -en "Frequence:\n1\t32\n2\t64\n3\t128\nAny other key\t128\n"
read freq
case $freq in
1)
freq1=32
;;
2)
freq1=64
;;
3)
freq1=128
;;
*)
freq=128
esac
for i in `seq 1 $num`
do
if ( cdda2wav -D $AUDIO_DEVICE -x -H -O wav -t $i track-$i.wav)
then
echo -e "\aTrack $i ripped; please type the track name"
read tt
if [ $sep ]; then
echo "Artist ..."
read artistname
fi
ttfilename=`echo $tt|gawk '{print $1}'`
if [ -e `echo $tt|gawk '{print $1".mp3"}'` ]
then
ttfilename=$ttfilename`date '+%s'|md5sum|gawk '{print $1}'`
fi
if (lame --tt "$tt" --ta "$artistname" --tl "$albumname" -b $freq1 track-$i.wav `echo "$ttfilename.mp3"`)
then
rm -fv track-$i.wav
echo -en "\e[32mTrack $i successfully ripped!\e[39m\n"
else
echo "Couldn't encode file"
exit 0
fi
else
exit 0
fi
done
Related download: Swobodin's MP3 Ripper - noversion