Conquer Giant FLAC

I have already written posts on splitting and converting from either album-length APE files or album-length FLAC files into track-length FLAC files.

(My post on converting APE files; my post on splitting APE files; my post on splitting FLAC files. You will want to go over these other articles if you have not done any of this before as there are some dependencies which you will not likely have installed.)

That was rather satisfying, but I then found that I would locate entire discographies where every album was a single APE or FLAC.  I did not enjoy the prospect of running each command on each pair of files.

That’s why scripting languages exist.  It’s a good thing I bought that BASH book.

Anyway, this script is designed to recursively locate APE, FLAC, and CUE files under a user-supplied root directory; then it runs shntool and cuetag on each APE/FLAC and CUE pair.  (You can read my previous posts linked above for more details about how these two commands work.)

It even cleans up after itself.  Since it deletes not only the temporary files it creates but also all the APE, FLAC, and CUE files it uses, you will want to pay close attention when the script tells you it is about to clean up all those files.  If you tell it to proceed (by hitting ENTER) without checking its work all those files will be deleted.  As such you should work from copies and you should check that it did what you wanted it to do before hitting ENTER when it asks about cleaning up all files.

Feel free to suggest any improvements.  I hope you find that it works well and improves your lives.

One important thing to note is that it is not an intelligent script.  It cannot determine for you whether a given APE or FLAC file is actually album length.  It assumes that you are offering it a folder (with or without sub-folders) which contains only album-length APE or album-length FLAC files with an accompanying CUE file (one matching pair per containing folder).

Sometimes a cue file will be formatted incorrectly or have some other issue.  Sometimes they can be fixed by opening them in a text editor.  Probably they can always be fixed in a text editor, but it might be difficult to determine what’s wrong with the CUE file.  If a CUE files has issues you will see errors on the command line (if you are staring at your monitor) and the album-length file will not be split/tagged.  You’ll have to work on that pair separately, but since you are working from copies it won’t matter if they get deleted.

If you throw something unusual at it, it’s hard to imagine how it might behave.  It’s likely not dangerous but you should always work from copies and preserve the originals until you are satisfied.

A couple of things have changed since I first wrote this script and article.  First, the script no longer accepts ape files as input.  You will want to convert them directly into flac files before splitting.  This is very easy and at some point I’ll add notes on how to do that.  Second, the script no longer lives here because it’s easier for me to maintain and share them over at GitHub. at GitHub

Have a great time!


4 thoughts on “Conquer Giant FLAC

  1. Hey, James, thanks for your reply to my blog at linuxquestions :). Thanks for the equation ( ff –> nnn) , too, such things are difficult to find when you happen to need them right away.

    I also analysed and answered your post and the answer may be of interest for you, as you’re trying to create an automated script.
    It’s all about the possible difference in formats used by, for example, WVPACK (by which many rips are created) and shntools, which we then use to split the *.wv rip created in WvPack and using the CUE sheets created by the same WvPack.
    Regarding your script, then, with a *.wv file you can, in all logic, assume its being created by WvPack — hence, the CUE format must be expected to be in “”, as per WvPack documentation, and not “hh:mm:ss.ff”, as shntools will assume.
    Sure, this brilliant guess needs being tested in real life, which I can’t do right now, sorry :(. As I was satisfied by my results, the possible inaccuracy thus created may have been quite trifling for human ear. Yet, for the sake of purity and mathematical exactitude it must be tested and verified, right?

    Thanks for the equation anyway, and for the script!! Really I had hard times trying to find any references online, except every now and then “good advise” to install certain stuff in MS Windows etc…

    1. The CD format (which is what shntools currently expects) is hh:mm:ss:ff (colon not dot). That makes it a little easier to identify (and hopefully to script).

      I hope to write a script to just convert cue files into the other format (change the colon to a dot and change the frames to thousandths of a second). I’m just not very good with sed and so am working very slowly to write the code to parse and convert all the correct time stamps in a cue file.

      Once that is done, the script above will work fine for them as well.

Leave a Reply to JamesIsIn Cancel reply

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