Ubuntu / Linux news and application reviews.

Did you ever downloaded a single APE or FLAC file consisting of multiple songs? If so, it's quite annoying to try and listen to only one song. But you can split the files into multiple songs exactly like in the cue file (each song's start and end time are saved in the cue file, so we'll know where to cut the big file).

What you need to split APE and FLAC files by Cue file

1. You need "cuebreakpoints" (part of "cuetools") and "shnsplit" (which is part of the "shntool"), so open a terminal and paste this:
sudo apt-get install cuetools shntool

2.

a) For APE files, you need to install the "Mac" package. This isn't in any repositories, but you can download a deb file from here.

b) For FLAC and WAV you need to install "flac" and "wavpack", so paste this in a terminal:
sudo apt-get install flac wavpack

Shnsplit requires a list of break-points with which to split an audio file. Conveniently, cuebreakpoints (part of cuetools) prints the break-points from a cue or toc file in a format that can be used by shnsplit.

Splitting the APE and FLAC files

Now, to split an APE file into multiple FLAC files (without the need to type the name of the .ape and .flac files), use the terminal to navigate to the folder where the APE file is located and type this in the terminal:
cuebreakpoints *.cue | shnsplit -o flac *.ape ;

To convert a large FLAC file intro multiple FLAC files (songs), the same as above, navigate using the terminal to the folder where the FLAC file is located and run this in the terminal:
cuebreakpoints *.cue | shnsplit -o flac *.flac ;

As you can see, the output file format is specified via the "-o" option. If you don’t specify an output format your split files will be in shntool’s default format (i.e., wave files, "wav").

After the splitting is complete, you will find in that folder some files named: split-track01.flac, split-track02.flac ... split-trackNN.flac. Each of that files is a song from the APE file. You can specify your own prefix (instead of "split-track") via the "-a" option.

Adding tags to the FLAC files so we'll see the song details (name, artist, etc) in our audio player

You will need "cuetag" for this which is part of the "cuetools" but since you already installed it (see previous seps), all you have to do is open the terminal, navigate to the folder where you just splitted some APE or FLAC files and type this:
cuetag *.cue split-track*.flac ;

(if you didn't change the file's name from split-trackNN.flac). All the split-track*.flac files will have tags in just a few seconds.

You can also conver an single .ape file to a single .flac file. To convert all .ape files in a directory to flac using shntool:
shntool conv -o flac *.ape