From 5f467eb1ed2ac9f08232d052e9c5553eb7aa763b Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 13 Oct 2021 19:02:23 +0200 Subject: [PATCH] small script to split flac+cue to flac tracks --- cue.to.flac.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 cue.to.flac.sh diff --git a/cue.to.flac.sh b/cue.to.flac.sh new file mode 100755 index 0000000..1e42310 --- /dev/null +++ b/cue.to.flac.sh @@ -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