CDRip Documentation


If you need any help customizing your installation, or if you think a feature needs to be added, just write a message in the project forums.


There are currently three different command-line arguments for CDRip: Device, Interactive mode, and Various mode. Specifying a device will override your default CD ripping drive.

$> cdrip /dev/hdd

Interactive mode will ask you if we are ripping a compilation CD. It will also display the available FreeDB information, and ask if you'd like to edit it. If you choose to edit the album info, you will be prompted line by line to type in new data. Don't worry, each field will still contain the FreeDB information by default. CDRip will automatically switch to Interactive mode if the FreeDB server doesn't return any information.

$> cdrip i

Finally, Various mode specifies that you are ripping a compilation CD. The Interactive mode won't ask you about this again if you enable both options. The entire point of this mode is to provide you with two different naming schemes for regular and compilation albums.

$> cdrip v

Of course, all these options can be used at the same time.


Your ~/.cdrip.conf file can be made up of pretty much whatever you wish, however there are some required variables and functions. Let's cover their uses and show some simple examples.


This variable should be set to the device we will be ripping from by default.

# OR "/dev/cdroms/cdrom0" for devfs

This variable allows you to enable Interactive mode by default. Remember, if Interactive is on by default, and you use the 'i' switch while running CDRip, you will be turning off the Interactive mode.


This function is used to determine the directory in which to store your albums. Variables are provided for the artist, year, and album names for organization. We can also restrict our names to legal characters for the file system (more or less). If you plan on ripping compilation albums, CDRip is designed to allow for different directory and file structure for these special cases.

outdirtemplate () {
  # NOT a compilation album
  if [[ $various != "1" ]] ; then
	echo "$HOME/music/$artist/$year - $album/"

  # an album with various artists
    echo "$HOME/music/various/$album/"

  fi |
  tr -cd "A-Za-z0-9 ()&,'/-"

Similar to the outdirtemplate function, this allows you to name your files. Additional variables for track number (2-digits) and track name are provided as well. Again, we can restrict file names to legal chars (more or less). Notice the only difference -- we don't allow / (forward slash) characters here.

outfiletemplate () {
  if [[ $various != "1" ]] ; then
	echo "$num - $name"
    # the track artist is included in the $name
    # in the format "Artist / Song Title"
    # .. convert / to -
	echo "$num - $name" | tr '/' '-'
  fi |
  tr -cd "A-Za-z0-9 ()&,'-"

This function is called within a loop. It is meant for running your CD ripper and encoder. The most common provided variables used here are:

# $i - the track number
# $outfile - the file name (from outfiletemplate)

rip () {
  cdparanoia -q -d $cddevice $i - |
  lame --preset standard - "$outfile.mp3"

This function is called before the loop which calls rip. You can use this to print out a message, or perhaps rip the entire album in one command, and use the rip function to just encode each track.

prerip () {
  echo "Ripping to $outdir"

Similar to prerip, this function is called after the loop which calls rip. If you like replaygain to calculate track and album peak values, this would be the perfect place to use it.

postrip () {
  mp3gain *.mp3
  echo "Done"
freedb, user, location

These are all variables related to accessing album data from the Internet. Pick a FreeDB server to use. They also want some information about us while we use their service.


Advanced Usage

Let's throw around some ideas for some of the near infinite uses of CDRip.

As stated above, the prerip function can be used to rip the entire album all at once. cdparanoia has an option to do a "batch rip", which rips every track into separate files.

prerip () {
  echo -n "Ripping the entire album to $outdir ... "
  # rip tracks 1 to the end
  cdparanoia -q -d $cddevice -B "1-" 
  echo "done!"

Now that we've got a bunch of huge wav files, let's compress them. For example's sake, let's say we like to backup our CDs with lossless compression, and encode them to small mp3s for our portable mp3 player, with ID3 tags.

# let's make an mp3 folder to keep things organized
prerip () { ... ; mkdir mp3 }

rip () {
  # this is the naming scheme cdparanoia uses in batch mode

  lame --ta "$artist" \
       --tl "$album" \
       --ty "$year" \
       --tt "$name" \
       --tn "$i" \
       --preset cbr 128 "$wavfile" "mp3/$outfile.mp3"
  flac -o "$outfile.flac" "$wavfile"

  # I believe flac deletes the wav file. Otherwise we should
  # rm "$wavfile"

Perhaps you have a cool mp3 jukebox on your network. You can rip your albums locally, and then move them onto the jukebox using Samba or NFS (assuming you have an entry in your fstab). If your jukebox is running an ftp server, you could look at using the wput tool to upload the files using the command line in a non-interactive, scriptable way.

postrip () {
  echo -n "Moving mp3s to the jukebox ... "
  mount /mnt/jukebox
  mv *.mp3 /mnt/jukebox
  umount /mnt/jukebox

  # wput -R *.mp3 ftp://user:pass@

  echo "done!"

Some people prefer to move "The" to the back of a band name, to keep them in alphabetical order. Also, some people like lower-case file names. In this example, we want the directory to have "the" move to the end, but tags will preserve the original form. If you want the change to be global, simply set the "artist" variable instead of "myartist".

outdirtemplate () {
  myartist=`echo $artist | sed 's/^the \(.*\)/\1, The/i'` # local

  echo "$HOME/music/$myartist - $year - $album/" |
  tr 'A-Z' 'a-z' |
  tr -cd "a-z0-9 ()&,'/-"

outfiletemplate () {
  echo "$num - $name" |
  tr 'A-Z' 'a-z' |
  tr -cd "a-z0-9 ()&,'-"

What if you only want to rip certain tracks from your albums? Perhaps you can prompt to ask if you'd like to rip each track (while in Interactive mode, for example).

# This function performs the actual ripping
actualrip () {
  echo -n "Ripping Track $num: $name ... "
  cdparanoia -q -d $cddevice $i - |
  lame --silent --preset standard - "$outfile.mp3"
  echo "done!"

# This function is called by the main script
rip () {
  # Only ask if Interactive mode is on
  if [[ $interactive == "1" ]] ; then
    echo -n "Would you like to rip Track $num: $name? (Y/n) : "
    read reply

    # the default is to rip... unless they typed n or N
    if [[ ! ( $reply == "n" || $reply == "N") ]] ; then
      actualrip # the function we just defined above

  # Interactive is off. Just rip without prompting about each track

Alternatively, you can ask the user to type in a list of tracks (or track ranges) before the ripping takes place, using a method similar to the "batch" cdparanoia example above.

prerip () {
  echo -n "Which tracks should we rip? [1- (All)] : "
  read reply

  if [[ $reply == "" ]] ; then

  for x in $reply ; do
    cdparanoia -q -d $cddevice -B "$x"

When this script asks which tracks to rip, we can reply 1-3 6 8- ... This will rip all tracks except 4, 5 and 7 (one through three, six, eight until the end). You can specify individual tracks, or track ranges, separated by spaces.

Copyright © 2005 Paul Seropian. This is GPL software.