Skip to content

Instantly share code, notes, and snippets.

@imiric
Last active February 27, 2017 14:35
Show Gist options
  • Save imiric/9412857 to your computer and use it in GitHub Desktop.
Save imiric/9412857 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Split a FLAC file (including HD/96kHz) into individual files using a cue sheet
# Source: http://unix.stackexchange.com/a/63976/44047
cue_file="$1"
aud_file="$2"
time[0]="00:00.00"
c=1
for ts in $(cuebreakpoints "${cue_file}"); do
time[${c}]=${ts}
c=$((c+1))
done
time[${c}]='-0'
echo $time
for ((i=0;i<$((${#time[@]}-1));i++)); do
trackno=$(($i+1))
TRACKNUMBER="$(printf %02d ${trackno})"
title="$(cueprint --track-number ${trackno} -t '%t' "${cue_file}")"
flac --silent --exhaustive-model-search --skip=${time[$i]} --until=${time[$(($i+1))]} --tag=ARTIST="${ARTIST}" --tag=ALBUM="${ALBUM}" --tag=DATE="${DATE}" --tag=TITLE="${title}" --tag=TRACKNUMBER="${TRACKNUMBER}" "${aud_file}" --output-name="${TRACKNUMBER}. ${title}.flac"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment