Last active
May 11, 2022 12:48
-
-
Save savanovich/9dbe1134479879da43d3 to your computer and use it in GitHub Desktop.
Splits flac file to separate tracks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# !!! PREREQUISITES !!! | |
# chmod u+x ~/bin/flac.sh | |
# | |
# sudo apt install cuetools shntool enca | |
# | |
# sudo add-apt-repository -y ppa:flacon | |
# sudo apt-get update | |
# sudo apt-get install -y flacon | |
INPUT=${PWD##*/} | |
# Find CUE-file | |
CUEFILE=$(find . -maxdepth 1 -iname "*.cue" | head -n 1) | |
# Convert cue file to UTF8. | |
enconv -Lru -x UTF8 "$CUEFILE" | |
# Cut files | |
BIGONE=$(ls -S | grep -i --regex="\.ape\|\.flac\|\.wv" | head -n 1) | |
echo "$BIGONE" | |
echo "$CUEFILE" | |
cat "$CUEFILE" #| head -n 20 | |
while [ -z "$CONTINUE" ]; do | |
read -r -p "Are you sure want to continue [y/N] ?" CONTINUE; | |
done ; | |
if [ ! $CONTINUE == "y" ]; then | |
if [ ! $CONTINUE == "Y" ]; then | |
echo "Aborted..."; | |
exit 1; | |
fi | |
fi | |
echo "Executing..." | |
if [ -n "$BIGONE" ] | |
then | |
cuebreakpoints "$CUEFILE" | shnsplit -o flac "$BIGONE" | |
else | |
exit 1 | |
fi | |
# Read tags in the CUE-file and write to flac-s. | |
cuetag "$CUEFILE" split-track*.flac ; | |
# Uncomment needed | |
#rm -f "$BIGONE" | |
#rm *.log | |
#rm *.cue | |
# Rename occording to tags | |
for SLICE in split-track*.flac; do | |
ARTIST=$(metaflac "$SLICE" --show-tag=ARTIST | sed s/.*=//g) | |
TITLE=$(metaflac "$SLICE" --show-tag=TITLE | sed s/.*=//g | tr "\/" "-") | |
TRACKNUMBER=$(metaflac "$SLICE" --show-tag=TRACKNUMBER | sed s/.*=//g) | |
mv "$SLICE" "`printf %02g $TRACKNUMBER` - $ARTIST - $TITLE.flac" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment