#!/bin/bash # # converts seconds to minutes, seconds and CD frames (for burning CDs with a cue file from Audacity label track) # and converts Audacity label file to cue sheet # # Sunday 29 May 2011 1:48pm # Prickle-Prickle, the 3rd day of Confusion in the YOLD 3177 # # written by DJ Kaboodle - http://www.djkaboodle.co.uk # # # programs needed to run this script: zenity, tr, cut, bc, special supplemental bc file, sed # the following line allows spaces to be used in filenames IFS=$'\t\n' for direct in `find -iname 'labels.txt' -printf '%h\n' > folderstemp.txt; cat folderstemp.txt | sort -u`; do curdirect=`pwd`; cd "$direct"; echo "$direct"; # album information performer=`zenity --entry --entry-text="" --text="enter ALBUM artist/performer here:"` albumtitle=`zenity --entry --entry-text="" --text="enter ALBUM title here:"` soundfile=`ls *.wav` # Maybe change above in case more than one wav file is found, and offer user a selection from a file list. echo "PERFORMER \"$performer\"" | cat > "${soundfile%%.*}.cue"; echo "TITLE \"$albumtitle\"" | cat >> "${soundfile%%.*}.cue"; echo "FILE \"$soundfile\" WAVE" | cat >> "${soundfile%%.*}.cue"; # change this number if wanting to start audio tracks with '00' or something else tracknum=01; while read line; do decseconds=`echo "$line" | cut -f1 | tr -d [:blank:]`; labeltitle=`echo "$line" | cut -f3`; # Might need to change the 'cut' delimiter below to something else for song names containing a tilde (~)? # track information artist=`echo "$labeltitle" | cut -d "~" -f1 | sed 's/^[ \t]*//;s/[ \t]*$//'`; songtitle=`echo "$labeltitle" | cut -d "~" -f2-20 | sed 's/^[ \t]*//;s/[ \t]*$//'`; echo " TRACK $tracknum AUDIO" | cat >> "${soundfile%%.*}.cue"; echo " PERFORMER \"$artist\"" | cat >> "${soundfile%%.*}.cue"; echo " TITLE \"$songtitle\"" | cat >> "${soundfile%%.*}.cue"; minutes=`echo "floor($decseconds/60)" | bc ~/bc | sed -e 's/^\([0-9]\)$/0\1/'`; tempseconds=`echo "scale=9; ($decseconds/60)" | bc | cut -d "." -f2 | sed -e 's/^/\./g'`; seconds=`echo "floor($tempseconds*60)" | bc ~/bc | sed -e 's/^\([0-9]\)$/0\1/'`; tempframes1=`echo "scale=9; ($tempseconds*60)" | bc | cut -d "." -f2 | sed -e 's/^/\./g'`; # the calculation below ensures that the number is always rounded to the nearest integer - without adding 0.5, it will not round anything of 0.6 up to 1, which is needed for this to work; 'scale=18' ensures there are 18 places to the right of the decimal point, for complete accuracy tempframes2=`echo "scale=18; ($tempframes1/0.013333333333333333)+0.5" | bc`; frames=`echo "floor($tempframes2)" | bc ~/bc | sed -e 's/^\([0-9]\)$/0\1/'`; indextime=`echo "$minutes:$seconds:$frames"`; echo " INDEX 01 $indextime" | cat >> "${soundfile%%.*}.cue"; tracknum=$[tracknum+1]; # end of while loop done