Skip to content

HowTo - Split a FLAC File Using the CUE Sheet

Don’t you hate it when your bittorrent download of an album finishes, and you realize that it’s one flac file and one cue file? Unless your goal is to recreate the CD, this format probably won’t be much good to you. You probably want a separate flac file for each song. Splitting the file is easy if you have the right tools. Follow these steps to install and use Free software to do just that.

Get the Tools
You need shntool and cuetools.
Ubuntu users can install these with the package manager.
Fedora users need to compile from source.

  1. Download the sources: cuetools-1.3.1.tar.gz shntool-3.0.3.tar.gz
  2. Extract.
  3. Install gcc if you haven’t already.
    yum -y install gcc gcc-c++
  4. Compile and install the programs with ./configure ; make ; make install

Split the File
Run this command to split the file using the cue sheet.

cuebreakpoints sample.cue | shnsplit -o flac sample.flac

19 Comments

  1. henriquemaia

    I had some CDs merged in one flac and I followed this howto with success. Thanks for this post.

    Posted on 07-Oct-07 at 2:39 pm | Permalink
  2. CDs downloaded in flac/cue format are soooooo useless. Thanks for the info ;)

    Posted on 10-Oct-07 at 4:39 pm | Permalink
  3. Michael

    FLAC can do it without external programs (given the flac file is “test.flac”, the cue file is “test.cue” and both are in the same directory):

    flac –decode –cue=- test.flac

    Posted on 21-Oct-07 at 4:47 pm | Permalink
  4. This is pretty useful, I download music all the time and I hate it when I just get a huge file. Dammit, I want my music mobile =(. Well, thanks to you, now I do.

    Posted on 11-Nov-07 at 9:58 am | Permalink
  5. alleyoopster

    If you want to put the tag info back in (shnsplit does not do it) you can use cuetag (available with cuetools)

    cuetag sample.cue split-track01.flac split-track02.flac split-track03.flac split-track04.flac

    or

    cuetag sample.cue split-track*.flac

    PS I couldn’t get the suggestion from Michael to work

    Posted on 31-Jan-08 at 4:30 pm | Permalink
  6. kjd

    “cuetag sample.cue split-track*.flac”

    That doesn’t work. Any ideas?

    Posted on 20-Feb-08 at 3:41 pm | Permalink
  7. Hell yeah man! You’re a life saver, works like a charm :).

    Posted on 21-Feb-08 at 1:11 am | Permalink
  8. alleyoopster

    kjd: Did you get any errors? Whats the problem?

    Try

    cuetag.sh sample.cue split-track*.flac

    Posted on 23-Feb-08 at 12:38 pm | Permalink
  9. Anonymous

    cuetag is crazy buggy and doesn’t play well with files that have spaces in them, nor does it work with recent versions of metaflac due to the use of flags that don’t exist (–remove-vc-all, –import-vc-from).

    Posted on 24-Feb-08 at 1:26 pm | Permalink
  10. alleyoopster

    I managed to convert all my collection (single flac > flac > ogg) this weekend and keep tags. I did have some problems with cuetag including the spaces in filename problem, but worked around them. I also found easytag and musicpicard could easily pick up the slack.

    Posted on 24-Feb-08 at 5:52 pm | Permalink
  11. mv

    Thanks for the tip :)
    I’ve used it successfully to convert from a single APE+CUE to multiple FLACs:

    cuebreakpoints CDImage.cue | shnsplit -i ape -o flac CDImage.ape

    Posted on 05-Apr-08 at 5:07 am | Permalink
  12. alleyoopster

    There is also an all in one solution - KDE app called soundKonverter

    Posted on 06-Apr-08 at 5:17 am | Permalink
  13. alleyoopster

    Please ignore last comment, I was temporarily on another planet. soundKonverter does not do this, but it is a good app.

    Posted on 06-Apr-08 at 5:20 am | Permalink
  14. kamahl

    Thanks a lot :-) this is just what I needed.

    Posted on 08-Apr-08 at 2:53 am | Permalink
  15. svenjohan

    I made a little script to automate the splitting and naming process since cuetag doesn’t seem to work very well.

    Nothing fancy, doesn’t tag files or anything like that, just splits and names the files accordingly.

    #!/bin/bash
    #two arguments - cue file and flac-file
    CUESHEET=$1
    FLACFILE=$2
    VA=no
    IFS=$’\n’
    NROFTRACKS=0

    cuebreakpoints “$CUESHEET” | shnsplit -o flac “$FLACFILE”

    #Should we tag each file with artist?
    ARTIST1=”`cueprint \”$CUESHEET\” -n1 -t \”%c %p\n\”`”
    for ARTIST in `cueprint “$CUESHEET” -t “%c %p\n”`; do
    if [ "$ARTIST" != "$ARTIST1" ]; then
    VA=yes
    fi
    NROFTRACKS=$((NROFTRACKS + 1))
    done

    for FILE in split*.flac; do
    TRACKNUM=`echo $FILE | cut -b12-13`
    KOMMAND=”mv \”$FILE\”"
    if [ $VA = "yes" ]; then
    NEWFILENAME=”`cueprint \”$CUESHEET\” -n$TRACKNUM -t \”%02n - %c %p - %t\n\”`.flac”
    else NEWFILENAME=”`cueprint \”$CUESHEET\” -n$TRACKNUM -t \”%02n - %t\n\”`.flac”
    fi

    mv “$FILE” “$NEWFILENAME”

    done

    Paste it in a file, splitcue.sh or something, then do `chmod +x splitcue.sh` and place in somewhere in your path (e.g. /usr/bin)

    Posted on 25-Apr-08 at 7:38 am | Permalink
  16. balazs

    Blessed you are svenjohan, I was just saying someone should write such a script and was going to start it when I found this thread. It worked perfectly and did exactly what I wanted.

    Posted on 02-May-08 at 12:43 am | Permalink
  17. pb

    I “fixed” cuetag by adding some “” and updating the options for metaflac. But as it seems like one has to register at BerliOS to submit patches, I’ll post it here. :P
    The following patch is against cuetag(.sh) from cuetools 1.3.1:
    Edited by James to fix formatting.

    --- /usr/bin/cuetag 2006-09-06 20:24:47.000000000 +0200
    +++ /usr/local/bin/cuetag 2008-05-08 13:01:44.000000000 +0200
    @@ -17,8 +17,9 @@
    vorbis()
    {
    # FLAC tagging
    - # --remove-vc-all overwrites existing comments
    - METAFLAC="metaflac --remove-vc-all --import-vc-from=-"
    + # --remove-all-tags removes tags
    + # --import-tags-from imports new tags from STDIN
    + METAFLAC="metaflac --remove-all-tags --import-tags-from=-"

    # Ogg Vorbis tagging
    # -w overwrites existing comments
    @@ -63,7 +64,7 @@
    (for field in $fields; do
    value=""
    for conv in `eval echo \\$$field`; do
    - value=`$CUEPRINT -n $1 -t "$conv\n" $cue_file`
    + value=`$CUEPRINT -n $1 -t "$conv\n" "$cue_file"`

    if [ -n "$value" ]; then
    echo “$field=$value”
    @@ -141,7 +142,7 @@
    cue_file=$1
    shift

    - ntrack=`cueprint -d ‘%N’ $cue_file`
    + ntrack=`cueprint -d ‘%N’ “$cue_file”`
    trackno=1

    if [ $# -ne $ntrack ]; then

    Posted on 08-May-08 at 6:11 am | Permalink
  18. pb

    Oh my, damn autoformatting from Wordpress. Get the patch here: http://pastebin.com/f41a1f6a6

    Posted on 08-May-08 at 6:13 am | Permalink
  19. Thanks heaps for the tut. I had issues with my codecs for those who are having issues make sure you install codecs.

    Posted on 16-May-08 at 9:34 am | Permalink

One Trackback/Pingback

  1. [...] informacion esta tomada do seguinte post. Percisan-se as seguintes utilidades,  cuetools, shntool e flac. Todas elas poden-se desgcargar [...]

Post a Comment

Your email is never published nor shared.