X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/04fed8e4657d28df3ca947ea34c2a5d8f9ccc02f..61d7dd11d4a450a64f2817ee4db0ec7fa5880b42:/bin/flaccue2flac diff --git a/bin/flaccue2flac b/bin/flaccue2flac new file mode 100755 index 0000000..4c692cf --- /dev/null +++ b/bin/flaccue2flac @@ -0,0 +1,97 @@ +#!/bin/bash + +clear + +# Introduction + +echo +echo +echo "FLACCUE2FLAC" +echo +echo +echo +echo "This script will convert, split and tag FLAC files with an associated cue sheet" +echo +echo +echo "WARNING: THIS SCRIPT WILL AUTOMATICALLY INSTALL SOME NECESSARY PACKAGES IF NOT ALREADY INSTALLED" +echo +echo +echo +echo + +# This will check if all packages needed are present in the system, and will install them if not. + +FLAC=`which flac` +if [ -z $FLAC ]; then +echo "ERROR (Don't worry) ;-)" +echo "FLAC is not in your system, automatically installing..." +sudo aptitude update && sudo aptitude install flac -y +clear +echo "OK NOW, PROCEEDING..." +echo +fi + +CUE=`which cuebreakpoints` +if [ -z $CUE ]; then +echo "ERROR (Wish every error were like this one...) ;-)" +echo +echo "cuetools not present, automatically installing..." +sudo aptitude update && sudo aptitude install cuetools -y +clear +echo "OK NOW, PROCEEDING..." +echo +fi + +SHN=`which shntool` +if [ -z $SHN ]; then +echo "ERROR (Not the end of the world, anyway) ;-)" +echo +echo "shntool is not around here, let's get it..." +sudo aptitude update && sudo aptitude install shntool -y +clear +echo "OK, PROCEEDING..." +echo +fi + +LL=`which lltag` +if [ -z $LL ]; then +echo "OH, MY GOD! ;-)" +echo +echo "lltag is not in your computer, installing..." +sudo aptitude update && sudo aptitude install lltag -y +clear +echo "AT LAST, PROCEEDING..." +echo +fi + +# Now it will check if we have chosen a cue file + +for i in $*; do +case $i in +*.[cU][uU][eE]) +echo "Checking if file $i is a .cue file...";; +*) +echo "Warning: File $i is not a .cue file. Aborting." +continue +esac + +# Processing files + +FILENAME="$(basename $i)" +FILENAME="${FILENAME%.[cC][uU][eE]}" + +echo "Splitting files..." +cuebreakpoints $FILENAME.cue +shnsplit -o flac -f $FILENAME.cue $FILENAME.flac + +echo "Adding tags..." +cuetag $FILENAME.cue split-track*.flac + +# This will rename files using the strucure "track-number title", the one I like, but it can be easyly changed using common parameters. Please read lltag manual for more information. + +echo "Renaming files..." +lltag --yes --no-tagging --rename '%n %t' `ls split-track*.flac` +echo +echo +echo "Process ended." +done