Split flac file into tracks using a cuesheet

      1 Comment on Split flac file into tracks using a cuesheet

shnsplit (part of the “multi-purpose WAVE data processing and reporting utility” shntool package) provides a simple method to split flac files into individual tracks specified in a cuesheet.

$ shnsplit -o flac -f CUESHEET.cue -t %n.%t FLACFILE.flac

With the custom output format module, you can even transcode the tracks directly to another format, e.g. mp3, if your mobile music player doesn’t support flac.

snippets.dzone.com provides an exemplary script for this.

#!/bin/sh
set -e
ENCODE="cust ext=mp3 lame -b 192 - %f"
FORMAT="%n.%t"

FLACFILE=$1
CUEFILE=$2
echo $FLACFILE - $CUEFILE
if [ -z "$FLACFILE" ]; then
    echo "usage: flac2mp3 FLAC_FILE [CUE_FILE]"
    exit 1
elif [ -z "$CUEFILE" ]; then
    DIRECTORY=$(dirname "$FLACFILE")
    BASENAME=$(basename "$FLACFILE" ".flac")
    CUEFILE="$DIRECTORY/$BASENAME.cue"
fi

shnsplit -O always -o "$ENCODE" -f "$CUEFILE" -t "$FORMAT" "$FLACFILE"

1 thought on “Split flac file into tracks using a cuesheet

Leave a Reply

Your email address will not be published.

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