small script to split flac+cue to flac tracks

This commit is contained in:
gardouille 2021-10-13 19:02:23 +02:00
parent 6a58b9fa9f
commit 5f467eb1ed
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

45
cue.to.flac.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
# This script take a directory as first argument
# AND will try to :
# * split the main flac file to several tracks with cue file
# * tag flac tracks with cue data
flac_dir="${1}"
if [ ! -d "${flac_dir}" ]; then
printf '%b' "Please give a directory as first argument."
exit 1
fi
# Dependancies {{{
if ! command -v shnsplit > /dev/null; then
printf '%b' "Please install shntool."
exit 1
fi
if ! command -v cuetag > /dev/null; then
printf '%b' "Please install cuetools."
exit 1
fi
# }}}
# Go to the directory
cd "${flac_dir}" > /dev/null || exit 1
main_flac_file=$(ls -S1 *.flac | head --lines=1 --)
main_cue_file=$(ls -S1 *.cue | head --lines=1 --)
# Split main flac file
shnsplit -f "${main_cue_file}" -t %n.%t -o flac "${main_flac_file}"
# Rename pregap file
mv 00.pregap.flac pregap.flac
# Tag flac tracks
cuetag "${main_cue_file}" [0-9]*.flac
# Go back to the previous directory
cd - > /dev/null || exit 1
# Success
exit 0