FLACRIPPER released! (updated)

I am going to be ripping a whole lot of CDs in order to digitize my CD collection (500+ CDs). I want lossless or close to lossless FLAC files of every single one. But I am lazy. And the GTK based rippers are slow and cumbersome (i.e. require my attention). Why not just drop down to the commandline and run cdparanoia? But then I’d still have to FLAC’em and tag’em, sort out the folders and correct wrongly named files..

This is where you go "There’s an app for that!" and narrowly escape my swinging fist. Of course there is. There are millions of apps– I mean programs that does this. But this is also the perfect excuse for actually getting to know bash scripting in GNU/Linux, and at a comfortably simple level. So for the last 3-4 days I’ve been writing a bash utility called FLACRIPPER that does exactly what I wanted and MORE. Which explains the 1.2 version number:)

FLACRIPPER in action
Ripping Stranger in Moscow because it’s the shortest single I have

The GPL v3 licensed source is here:
Flacripper (directory): sigg3.net/blogger/flacripper/
Flacripper (latest): sigg3.net/blogger/flacripper/flacripper.sh.txt
Please report bugs in the comments or by this form.

Essentially, it’s just a smart bash script that runs Monty’s cdparanoia and Josh Coalson’s flac. But it also queries the CDDB (freedb.org) music info database using cddb_query, auto-tags files with metatag after you’ve confirmed them (see screenshot), creates directories and keeps a log of your ripping. Script has been updated to accept commandline arguments (see below).

Just edit the .sh file in your favourite editor (e.g. nano). It’s pretty simple:


# Path to your music root directory (NO trailing slash!)

# FLAC compression level (0 is none, 8 is full)

# Keep original WAV files? (default: disabled)

# Enable log? (saves flacripper.log in $musicdir)

# Enable log check? (default: enabled)
# Exits if disc ID is found in log file, but without regard
# for earlier erraneous rips and CDDB ID duplicates.

# Confirm CDDB information? (default: enabled)
# Leave enabled to avoid CDDB misinformation. Laziness is key.
# (e.g. "Michael Jackson" vs. "Jackson, Michael" artist field)

So far it’s only been tested on my Fedora 17 machine, but it should work on any GNU/Linux operating system as long as these dependencies are met: cddb, cdparanoia, eject, flac and metaflac.


# DEPENDENCIES: cddb, cdparanoia, eject, flac, metaflac
wget http://sigg3.net/blogger/flacripper/flacripper.sh.txt .
nano flacripper.sh.txt # Edit config section if you want to
mv flacripper.sh.txt flacripper
chmod +x flacripper
mv flacripper /usr/local/bin/

The out of the box experience will rip your CD to WAV, convert these to flac using compression level 2, create folders in your root music dir /ARTIST/ALBUM and tag the flac files according to the CDDB query. If the CDDB query fails, which can happen on brand new CDs as well as obscure ones, flacripper will dump you into an ncurses based interactive editing mode PRIOR to ripping. Cdparanoia is excellent, but can be slow if your media is scratched/old, so the idea is to get all the information gathering done before the machine takes over.

If your CD is known you’ll usually: put it in the drive, type flacripper go [ENTER] and hit [ENTER] to confirm artist and album info. That’s it. If your CD is unknown to freedb.org you’ll be asked to enter Artist, Album name, Genre, Year and the track list before the machine takes over.

What have I learned?
Much thanks to The Linux Commandline and Shell Scripting Bible by Richard Blum, I was able to solve most problems without resorting to google, which was sort of the point. I’ve come to learn a lot about sed, awk and tr, which are excellent tools for manipulating piped output, and without which I wouldn’t know where to begin. But I have much to learn, so I decided to release my godawful code under the GPL v3. I know there are many places where I could probably just reverse the stream to avoid temp files, but I’m not too confident about that just yet. Thanks to the brilliant guys @ bash.cyberciti.biz for their dialog –form write-up and BeGood at stackoverflow.com for a nice renaming while-loop. Happy ripping!

EDIT: UPDATED to version 1.2.2
Fixed a bug where a couple of missing quotes left 2 meta tag fields empty in configured mode. Updated the script so that it runs like a regular GNU/Linux utility:

  • To run in configured mode: $flacripper go 
  • To run in simple mode: $flacripper –quick 

I also added –help and –usage, the latter being displayed also if flacripper is run without arguments. –help will display the current configuration settings in addition to usual help information. Finally, I added a cleanup function to do a little housekeeping if flacripper receives SIGHUP, SIGINT or SIGTERM signal.

EDIT: UPDATED to version 1.2.3
Fixed a couple of bugs stemming from the feature creep above. Also added directory listing so you can browse the sources. I expect no other changes to the script from now on except bug fixes, though I am toying with the idea of an experimental post to $socialnetwork option.. But I need to move on to actually ripping CDs now, studies, and any bugs you can find or fixes you submit. Thanks!

7 thoughts on “FLACRIPPER released! (updated)

  1. Would be nice with the greater surface area, people actually using it, but it’s just a bash script really. The work is all done by cdparanoia, flac and metaflac. Haven’t seen bash scripts on github yet. But I’ll look into it fosho!

  2. Cheers! But why?
    The initial name was flacrip. I pondered on "Flac the Ripper" too, but there are many such projects in F/OSS.

  3. Cheers, man!
    I’m currently writing two exams, but I have created a github account where I’ll put it all (mid June).
    I have some other cool software as well:)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.