Monday, June 04, 2007

Splitting CUE/FLAC Files

I do so dislike large single files (unless it's a cue/bin of a game/software CD). Life just sucks when you have to deal with an album in the form of a single large audio file. At least it has a cue sheet, which creates the possibility of relatively easily splitting the file sanely.

And so, a little research lead me to this interesting command line:

~$ cuebreakpoints "filename.cue" | shntool split -o flac "filename.flac"

To work this little magic, you'll first need a few tiny packages installed. So, install cuetools & shntool like so:

~$ sudo apt-get install cuetools shntool

After which (assuming the cue/flac files are in your current working directory) you run the above mentioned command line to split the file into individual tracks named 001.flac, 002.flac, etc...

A little explanation is probably in order. I doubt I'd remember what the command means a few months from now. The first part of the command takes the cue sheet, and outputs where a track ends and the next begins:

cuebreakpoints "filename.cue"

Next, we redirect the output to shntool for splitting and naming:

shntool split -o flac "filename.flac"

Here, we're telling shntool that we want to split the flac file into individual files. Using -o flac means we want the output format to be in flac as well. There's other formats that could be specified including wave (just use -o wav instead). Read the manual for more info.

Note: You need to use shntool split -n '' -o flac "filename.flac" instead if you happen to have an older version of shntool.

Put everything together, and we have a fairly simple command to split cue/flac files into individual audio tracks. Enjoy! :-)

Related posts:

Dealing with uif files
Converting cue/bin to ISO
Converting CCD images to ISO