Split a FLAC and Tag the Children using Cue Information

It may come to pass that you download a concert or album only to discover that the encoder has helped you out by encoding the entire thing as a single FLAC file accompanied by a .cue file for determining the track changes.  Rhythmbox, for instance, will play these large FLAC’s just fine and it will even display the correct track information as you progress through the file.  However, I find it much more palatable to have single tracks be single files.

It’s actually pretty easy to break that large FLAC file into its component tracks and to add the appropriate tag information into those individual FLAC files.  It only requires a couple of lines of code, in fact.  The code may look complicated, but once you understand how to parse the different pieces you should have no difficulty in manipulating the code to process your files.

First I offer a couple of examples of how the code might look.  Suppose you have a folder which contains a Van Morrison album as a single flac (and the cue file is in there as well).  Open a terminal (Applications —> Accessories —> Terminal) and navigate into that folder (using the cd command).  Your commands might look like such:

  • shnsplit -o flac -f Van\ Morrison\ -\ Astral\ Weeks.cue -t “%n – %t” Van\ Morrison\ -\ Astral\ Weeks.flac
  • cuetag Van\ Morrison\ -\ Astral\ Weeks.cue 0*.flac

As I said, the code looks a little complex but let’s look at another example.  Suppose you have volume one from the Hôtel Costes series by Stéphane Pompougnac.  Your code might look like this:

  • shnsplit -o flac -f VA-Hotel_Costes_1.cue -t “%n – %t” VA-Hotel_Costes_1.flac
  • cuetag VA-Hotel_Costes_1.cue *.flac

As you can see, certain elements do not change.  What changes is your particular file names.  In the Van Morrison example the files contain spaces and said spaces must be preceded by a slash (\) in order to be taken as a space within the file name.  In the end what you are really seeing is this:

  • shnsplit -o flac -f [cuefile].cue -t “%n – %t” [albumflac].flac
  • (or shnsplit -o flac -f [cue\ file].cue -t “%n – %t” [album\ flac].flac)
  • cuetag [cuefile].cue *.flac
  • (or cuetag [cuefile].cue 0*.flac)

I like to change my FLAC  and cue files to the name a.  Then I can simply run:

  • shnsplit -o flac -f a.cue -t “%n – %t” a.flac
  • cuetag a.cue *.flac

(Be sure to either send the album FLAC to the trash or remove its file extension after running the first command be before running the second, or you will get an error about having the wrong number of FLAC files.)

(There is a problem if you attempt to copy and past from the above lines.  The quotation marks are different. So when you grab the part -t “%n. %t” you will have to replace the quotation marks by typing them fresh.  Alternatively, you can use the following code section for copying and pasting.)

#
#
#
shnsplit -o flac -f *.cue -t "%n - %t" *.flac

# now you may move or remove the album FLAC]

cuetag a.cue *.flac

This ought to work as a simple copy and paste assuming you have only one FLAC and one cue file in the folder in which you are working.  If you have a different arrangement you will want to replace each asterisk (*) with the correct file name.

Let me explain that zero (0) in the Van Morrison example.  That album happens to have fewer than 10 tracks.  So all of the tracks begin with a zero (01, 02, &c).  That is not the case on the Hôtel Costes album; it has tracks 11, 12, 13, &c.  You must add something like .remove to the album FLAC (so VA-Hotel_Costes_1.flac.remove) or move to different location (like the trash) after you have run the first command and before you run the second command (since the album FLAC file also ends in .flac and would be within the scope of *.flac).  If you leave the original FLAC within range, cuetag will inform you that the number of tracks does not match the number of cue breaks and it will not tag the files.  Not a big deal, but it could be a point of confusion if you were not prepared properly for it.

There are other arguments besides those which I used in my commands above.  You can read quite a lot about similar methods here.

Happy hunting, music lovers.

  • Share/Bookmark
-- ==
-- ==

4 Responses to “Split a FLAC and Tag the Children using Cue Information”

  1. James Cook JamesIsIn says:

    Looks like copying and pasting these commands includes some hidden character or attribute. If I get it sorted out I’ll post another comment but until then you’ll have to type the above commands into your terminal.

    Also, I removed the cuebreakpoints command (which I had formerly piped into the shntool command) because it appears that it is no longer required.

    • James Cook JamesIsIn says:

      Ok, the copy/paste problem is as follows. The quotation marks are different. So when you grab the part -t “%n. %t” you will have to replace the quotation marks by typing them fresh. Alternatively I will also add a code section above with a more general version of the code for copying and pasting.

  2. James Cook JamesIsIn says:

    For those interested in such things, %p is for Performer and %a is for Album (in case you’d like those in the file name). I never use Album in my file names, but for a various artist type album I do like to use Performer. Usually like this instead:

    “%n – %p – %t”

Leave a Reply