≡ Menu

Linux Rip Audio CD

  1. #!/bin/bash
  2. # A simple shell script to rip audio cd and create mp3 using lame
  3. # and cdparanoia utilities.
  4. # ----------------------------------------------------------------------------
  5. # Written by Vivek Gite <http://www.cyberciti.biz/>
  6. # (c) 2006 nixCraft under GNU GPL v2.0+
  7. # ----------------------------------------------------------------------------
  8. read -p "Starting in 5 seconds ( to abort press CTRL + C ) " -t 5
  9. cdparanoia -B
  10. for i in *.wav
  11. do
  12. lame --vbr-new -b 360 "$i" "${i%%.cdda.wav}.mp3"
  13. rm -f "$i"
  14. done

How Do I Use This Script?

Download the script. Put audio cd into drive. Create directory to store mp3s, enter:
mkdir music
cd music
mkdir "Album name"
cd !!:1

See HowTo: Linux Rip and Encode Audio CDs

Comments on this entry are closed.

  • http://freebsd.gaalweb.hu Peter Gaal

    petike-nb# abcde -a cddb,read,encode,tag,move,playlist,clean -d /dev/cdrom -o mp3 -V -x

  • https://github.com/Walter- Walter

    The script should read

    # A simple shell script to rip an audio CD and create MP3s using lame
    # and cdparanoia.
    # ----------------------------------------------------------------------------
    # Written by Vivek Gite  and WS
    # (c) 2011 nixCraft under GNU GPL v2.0+
    # ----------------------------------------------------------------------------
    read -p "Starting in 5 seconds (to abort press CTRL + C)" -t 5
    if ! cdparanoia -B; then
    	echo "cdparanoia ended with error, bailing out" 1>&2
    	exit 1
    for i in *.wav; do
    	if lame --vbr-new -q 0 "$i" "${i%%.cdda.wav}.mp3"; then
    		rm -f "$i"
    		echo "Could not encode $i" 1>&2
    exit $rc

    I corrected spelling and added error checking. The script will now abort on a ripping error and won’t delete Wave files which have not been successfully encoded.
    If any error occurs, the exit code is not 0.
    Furthermore, “–vbr-new” and “-b 360” are contradictory options, the first telling lame to use variable bit rate and the second telling lame to use constant bit rate for encoding. I replaced the second with “-q 0” to achieve the best possible result.
    The usage example could be simplified with

    mkdir -p "music/Album name"
    cd $?
  • https://github.com/Walter- Walter

    Oops, I used a wrong variable for the usage example ^^

    mkdir -p "music/Album name"
    cd !$
  • bas

    Very cool!
    But what about files name?
    Why i have to change handy?