#!/bin/bash NUMBER_OF_TRACKS=1 TRACK_NUMBER=1 SOURCE=/dev/cdrom HELP=0 KEEP=0 WAVONLY=0 if ps | grep lame 2>&1> /dev/null; then killall lame; fi if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then HELP=1; fi if [ "$1" = "-keep" ] || [ "$2" = "-keep" ] ; then KEEP=1; fi if [ "$1" = "-wavonly" ] || [ "$2" = "-wavonly" ] ; then KEEP=1; WAVONLY=1; fi #echo Debugging message: \$HELP=$HELP #echo Debugging message: \$KEEP=$KEEP #echo Debugging message: \$WAVONLY=$WAVONLY if [ $HELP = 1 ] then echo " \"rip\" the cd ripping program - extracts audio tracks from an audio CD" echo " and compresses them to mp3 files" echo echo " Usage: rip [ -help -keep -wavonly ]" echo " -help: Show this usage message and exit" echo " -keep: Keep .wav format files in seperate wav directory" echo " -wavonly: Extract tracks to uncompressed .wav files only, do not compress" exit 0 fi # Count and report number of audio tracks on current disk. while cdparanoia -d $SOURCE -Q 2>&1 | grep " $NUMBER_OF_TRACKS. " #>/dev/null; do NUMBER_OF_TRACKS=$(($NUMBER_OF_TRACKS + 1)); done NUMBER_OF_TRACKS=$(($NUMBER_OF_TRACKS -1 )) echo if [ $NUMBER_OF_TRACKS = 0 ]; then echo There are no audio tracks on this CD, or disk not found. else echo There are $NUMBER_OF_TRACKS audio tracks on this CD. fi echo if [ "$1" = "-check" ] || [ "$1" = "-Check" ]; then exit 1; fi if [ $NUMBER_OF_TRACKS = 0 ]; then exit 1; fi echo continuing ...; echo while [ $TRACK_NUMBER -le $NUMBER_OF_TRACKS ]; do #Pad with leading zeros so sort order == album order if [ $TRACK_NUMBER -le 9 ]; then TRACK_NO=0$TRACK_NUMBER; else TRACK_NO=$TRACK_NUMBER; fi; cdparanoia -d $SOURCE $TRACK_NUMBER $TRACK_NO.wav # In case disk space usage is an issue there's no point in letting cdparanoia # get more than one track ahead of lame. Thiss assumes that the compression # is much slower than the wav ripping. None of this pertains if you are # keeping the wave files, for instace to make another CD. while ps | grep lame 2>&1> /dev/null; do sleep 5 ; done if [ $KEEP = 0 ] then rm $PREV_TRACK.wav fi if [ $WAVONLY = 0 ] then echo Encoding $TRACK_NO.wav --\> $TRACK_NO.mp3; echo lame -quiet $TRACK_NO.wav $TRACK_NO-.mp3 2>/dev/null & fi PREV_TRACK=$TRACK_NO TRACK_NUMBER=$(($TRACK_NUMBER + 1 )); done if [ $KEEP = 0 ]; then rm $PREV_TRACK.wav; fi