A bash script that automatically splits single FLAC music album files into individual song tracks using CUE sheet information.
When digitizing an LP or ripping a CD to lossless format, the result is usually a single large FLAC file containing the entire music album, accompanied by a CUE sheet that defines individual song track boundaries. Popular ripping software like EAC (Exact Audio Copy), dBpoweramp, Whipper, and Rip Station often create these FLAC+CUE pairs to preserve perfect audio quality. While this format preserves the original recording perfectly, it's not convenient for modern music players that expect individual song files.
This script bridges that gap by:
- Splitting large music album files into individual song tracks
- Preserving audio quality (lossless FLAC-to-FLAC conversion)
- Organizing files with consistent naming (
01 - Song Title.flac) - Sanitizing filenames for cross-platform compatibility
- 🎵 Lossless splitting using shntool
- 📁 Recursive processing - automatically finds and processes all FLAC+CUE pairs in an entire directory tree
- 🔄 Smart duplicate detection (won't re-split already processed albums)
- 🖥️ NTFS compatibility (sanitizes problematic characters in track names)
- 🛡️ Safe operation (renames originals to
.delinstead of deleting) - 📊 Clear progress feedback with status messages
The script automatically sanitizes CUE file song titles to ensure compatibility with Windows NTFS filesystems by replacing problematic characters:
| Character | Replacement | Reason |
|---|---|---|
? * < > | / \ : |
- |
Reserved/illegal in Windows filenames |
Curly quotes (' ') |
- |
Encoding issues across systems |
This ensures your music library works seamlessly whether you're on Linux, macOS, or Windows.
The script requires these tools to be installed:
- shntool - for splitting audio files
- flac - for FLAC codec support
- Standard Unix tools (
sed,find,basename, etc.)
sudo apt-get install shntool flacbrew install shntool flacsudo dnf install shntool flacAfter installing the prerequisites above, you need to make the script available on your system:
sudo cp split_flac.sh /usr/local/bin/split_flac
sudo chmod +x /usr/local/bin/split_flacmkdir -p ~/.local/bin
cp split_flac.sh ~/.local/bin/split_flac
chmod +x ~/.local/bin/split_flacMake sure ~/.local/bin is in your PATH (it usually is by default on modern Linux distributions).
The power of this script lies in its recursive processing capability. Simply navigate to the top-level directory containing your music collection and run:
split_flacThe script will automatically:
- Traverse the entire directory tree recursively
- Find all music album FLAC+CUE file pairs at any depth
- Process each album it discovers
- Skip directories that have already been processed
This means you can organize your music collection like this:
Music/
├── Artist 1/
│ ├── Album A/
│ │ ├── Album A.flac
│ │ └── Album A.cue
│ └── Album B/
│ ├── Album B.flac
│ └── Album B.cue
└── Artist 2/
└── Album C/
├── Album C.flac
└── Album C.cue
And process everything with a single command from the Music/ directory.
Before:
Album/
├── Album Name.flac
└── Album Name.cue
After:
Album/
├── 01 - Opening Song.flac
├── 02 - Second Song.flac
├── 03 - Another Song.flac
├── Album Name.flac.del
└── Album Name.cue.del
- Non-destructive: Original files are renamed to
.del, not deleted - Skip protection: Won't re-process directories that already contain split song tracks
- Error handling: Reports failures and leaves originals untouched on errors
After verifying the split song tracks work correctly, you can remove the backup files:
find . -name "*.del" -deleteMIT License - see the script header for full details.
Issues and pull requests welcome! This script was created to solve a common problem in digital music archiving and is compatible with FLAC+CUE files created by EAC, dBpoweramp, Whipper, Rip Station, and other popular ripping software.
cue2tracks.shflac_album_splitter.shsplit_cue_flac.sh
The current name split_flac.sh was chosen for simplicity and clarity.
We have occasionally seen recordings consisting of .wv/.cue pairs (WavPack). This script currently does not split these. However, the underlying 'shntool' command that we are using supports the .wv format as well. The script could be modified to support .wv extensions, and the WavPack codecs can be installed with 'sudo apt-get install wavpack'.