29 August 2010

Batch CD and DVD ripping/burning

I was faced with the task of ripping a few box sets of DVDs and CDs today, and after a quick and fruitless “topeka” search for a way to automate this, I wantonly decided to write my own.

A short time later I had a nice Ruby script capable of ripping discs to images without any user input, except sticking in the next disc after one is ejected. It can also reverse the process and take sequentially named image files and burn them with the same ease.

I’d been wanting to try out this great Ruby gem “commander” for a while. It was a breeze to get a full-blown command-line interface up and running with this thing. Truly amazing, Ruby style. Following some very sage advice I have recently forsworn bash programming in favor of more friendly modern scripting languages, and I must say… I’m definitely not going back!

I was quite pleased with the way it turned out, so I thought I ought to share. This is another first for me today: it’s the first open source project I’ve released! Well, almost. I wrote a 4D fractal generator back in university, and it’s probably still lurking around on SourceForge somewhere… with a grand total of 240 downloads after 1964 days of inactivity :-P. It was pretty alpha-state software, so I’d be surprised if it got much use. I honestly still think about going back and improving it one of these days, when I have time. Haha… time. We’ll see eh?

Anyhow, I’ve called this script “Jack’s TehRipper”, and you can find it on Github at http://github.com/jacksenechal/TehRipper. I released it under the MIT license, so grab a copy, fork it to your heart’s content, whatever.

Using it is quite easy. Running tehripper by itself gives you a list of the available commands:

NAME:

  tehripper

DESCRIPTION:

  A program to batch read/write raw CD audio or CD/DVD data for backup

COMMANDS:

  help                 Display global or [command] help documentation.
  read-audio           Reads audio data from CD to new local directory, eg. "./cd1/"
  read-iso             Reads DVD image to working directory, eg. "./dvd1.iso"
  write-audio          Writes audio data to CD from local directory, eg. "./cd1/"
  write-iso            Writes DVD image from working directory, eg. "./dvd1.iso"

The commands also take some arguments, for instance:

OPTIONS:

  --start n
      The starting number for image file naming (defaults to 1)

  --end n
      The ending number for image file naming (defaults to 1)

  --prefix string
      The prefix for the image file name (defaults to "dvd")</pre>

So to copy a disc image in ISO format to your local working directory from a DVD in your drive, you would just say:

tehripper read-iso

Or to make ISOs of your uber-favorite i luv u 4evar 10-DVD set, you would issue a command like:

tehripper read-iso --start 1 --end 10 --prefix The_Princess_Bride_Collectors_Edition_Box_Set

How much cooler could that get?