Hello All,
First of all I am not a coder by any stretch of the imagination. I got a script off the internet and adapted it to my needs or the best that I could do, but it’s not quite there yet and I am pulling my hair out trying to get it to do what I would like . Please be gentle ok
I have this script that scans thru my entire music library. It gathers replaygain tag data and only logs to a text file any replaygain values lower than a number that I give it. So I tell it I want only anything lower than -4dB replaygain_track_gain to be sent to a log and it does just that but I can’t seem to get it to log anything other than replaygain_track_gain?? So my goal is to start low, say around -10dB on the replaygain value and look thru those flacs for clipping and fix them. Then go to -9dB and so on. What I have found is that almost all of the flacs I have with a replaygain value of -10dB or more have some clipping on them, and the higher I go towards 0dB acorrding to replaygain data the clipping drops off accordingly, and it seems that usually anything above -5dB(going towards 0dB) is normally a clean track or album(usually). Like I said, the script works as it should but just isn’t giving me all the info I need, which is ARTIST, TITLE, REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_ALBUM_GAIN. Here is an example of what I would like to see:
The script that produced this snippet works well, but it doesn’t sort the replaygain values. I don’t need the ones that are say, above -4dB(going towards 0dB) because chances are they aren’t clipped.
Tag Values Retrieved:
artist=Fleetwood Mac
title=Second Hand News
REPLAYGAIN_TRACK_GAIN=-8.88 dB
REPLAYGAIN_ALBUM_GAIN=-7.71 dB
artist=Fleetwood Mac
title=Dreams
REPLAYGAIN_TRACK_GAIN=-6.65 dB
REPLAYGAIN_ALBUM_GAIN=-7.71 dB
artist=Fleetwood Mac
title=Never Going Back Again
REPLAYGAIN_TRACK_GAIN=-3.49 dB
REPLAYGAIN_ALBUM_GAIN=-7.71 dB
And this snippet is the same script with the awk sorting command inserted into the script which sorts the replaygain values nicely but doesn’t give me the info as above nice and proper in it’s place.
/media/Storage/Music/Rock/Coldplay - Discography Lite/2002-08-26 - A Rush of Blood to the Head - Parlophone 540 5042 GB (11 FLAC files)
Tag Values Retrieved:
REPLAYGAIN_TRACK_GAIN=-8.52 dB
REPLAYGAIN_TRACK_GAIN=-8.67 dB
REPLAYGAIN_TRACK_GAIN=-9.28 dB
REPLAYGAIN_TRACK_GAIN=-8.72 dB
REPLAYGAIN_TRACK_GAIN=-8.85 dB
REPLAYGAIN_TRACK_GAIN=-9.00 dB
REPLAYGAIN_TRACK_GAIN=-9.58 dB
REPLAYGAIN_TRACK_GAIN=-8.31 dB
REPLAYGAIN_TRACK_GAIN=-8.98 dB
/media/Storage/Music/Rock/Coldplay - Discography Lite/2011-10-21 - Mylo Xyloto - Parlophone 087 5532 DE (14 FLAC files)
Tag Values Retrieved:
REPLAYGAIN_TRACK_GAIN=-9.34 dB
REPLAYGAIN_TRACK_GAIN=-9.46 dB
REPLAYGAIN_TRACK_GAIN=-9.54 dB
REPLAYGAIN_TRACK_GAIN=-8.83 dB
REPLAYGAIN_TRACK_GAIN=-9.63 dB
REPLAYGAIN_TRACK_GAIN=-8.68 dB
REPLAYGAIN_TRACK_GAIN=-8.82 dB
/media/Storage/Music/Rock/Coldplay - Discography Lite/2005-06-06 - X&Y - (no release info) AU (13 FLAC files)
Tag Values Retrieved:
REPLAYGAIN_TRACK_GAIN=-8.67 dB
REPLAYGAIN_TRACK_GAIN=-9.09 dB
REPLAYGAIN_TRACK_GAIN=-8.94 dB
REPLAYGAIN_TRACK_GAIN=-9.63 dB
REPLAYGAIN_TRACK_GAIN=-8.11 dB
REPLAYGAIN_TRACK_GAIN=-9.40 dB
REPLAYGAIN_TRACK_GAIN=-8.85 dB
REPLAYGAIN_TRACK_GAIN=-8.98 dB
REPLAYGAIN_TRACK_GAIN=-8.87 dB
REPLAYGAIN_TRACK_GAIN=-8.89 dB
REPLAYGAIN_TRACK_GAIN=-8.62 dB
REPLAYGAIN_TRACK_GAIN=-9.66 dB
And here is the script
#!/bin/bash -u
echo "You entered: '${*-}'"
(
if [ ! -d "$1" ]
then
echo "Arg "$1" is NOT a directory!"
exit $ARGUMENT_NOT_DIRECTORY
fi
flacnum=`ls "$1" | grep -c \.flac`
if [ $flacnum -lt 1 ]
then
echo $1" (No FLAC files, moving on)"
exit 0
else
echo $1" ("$flacnum" FLAC files)"
fi
echo "Tag Values Retrieved:"
flacfiles=`ls -1 "$1"/*.flac`
IFS=$'\012'
for file in $flacfiles
do metaflac --show-tag=ALBUM --show-tag=TITLE --show-tag=REPLAYGAIN_TRACK_GAIN --show-tag=REPLAYGAIN_ALBUM_GAIN "$file" | awk 'BEGIN {FS="[ =]"}; $(NF-1)[b]<-8[/b] { print }'
#The number above in bold is adjusted to log only tracks that go below, in this case, -8dB.
done) 2>&1 | tee -a rgainvaluesMUSIC.log
I use this script to call the above scritp:
#!/bin/bash
#This script calls metadata1.sh in my home directory to search recursively thru the music #library for replaygain values lower than any number I give it i.e.-4dB, -5dB -8dB ect.ect.
# Define error codes
ARGUMENT_NOT_DIRECTORY=10
FILE_NOT_FOUND=11
# Check that the argument passed to this script is a directory.
# If it's not, then exit with an error code.
if [ ! -d "$1" ]
then
echo "Arg "$1" is NOT a directory!"
exit $ARGUMENT_NOT_DIRECTORY
fi
echo "********************************************************"
echo "Calling metadata1.sh on each directory in:"
echo $1
echo ""
find "$1" -type d -exec ~/metadata1.sh '{}' ;
I am sure the problem lies in the awk command of the script. Some descriptor not allowing it to print out what I would like but for the life of me I can’t figure it out and get it to do what I want.
So that’s it, I guess. I would like to thank you for any help in advance that you could be so kind to pass along to an older fellow whose brain isn’t what it used to be.
Cheers,
Singtoh