Quote Originally Posted by Vaphell View Post
file with dummy data:
Code:
artist=AAA
album=AAA
title=AAA
REPLAYGAIN_ALBUM_GAIN=-5.09 dB
REPLAYGAIN_TRACK_GAIN=-5.51 dB
-----
artist=BBB
album=BBB
title=BBB
REPLAYGAIN_ALBUM_GAIN=-6.09 dB
REPLAYGAIN_TRACK_GAIN=-6.31 dB
-----
artist=CCC
album=CCC
title=CCC
REPLAYGAIN_ALBUM_GAIN=-7.09 dB
REPLAYGAIN_TRACK_GAIN=-7.09 dB
-----
artist=DDD
album=DDD
title=DDD
REPLAYGAIN_ALBUM_GAIN=-8.09 dB
REPLAYGAIN_TRACK_GAIN=-8.09 dB
-----
artist=EEE
album=EEE
title=EEE
REPLAYGAIN_ALBUM_GAIN=-18.09 dB
REPLAYGAIN_TRACK_GAIN=-18.09 dB
-----
gain.awk
Code:
#!/usr/bin/awk -f

        BEGIN { FS="[ =]"; ag=1000; tg=1000; }
    /artist=/ { a=$0; }
     /title=/ { t=$0; }
     /album=/ { al=$0; }
/ALBUM_GAIN=/ { ag=$2; }
/TRACK_GAIN=/ { tg=$2; }
       /----/ {
                if( tg<x )
                { 
                  print a; print t; print al;
                  printf("track gain: %s, album gain: %s\n", tg, ag);
                  print "---------";
                }
                a=""; t=""; al=""; ag=1000; tg=1000;
              }
Code:
$ ./gain.awk -v x=-4 gain_test.txt 
artist=AAA
title=AAA
album=AAA
track gain: -5.51, album gain: -5.09
---------
artist=BBB
title=BBB
album=BBB
track gain: -6.31, album gain: -6.09
---------
artist=CCC
title=CCC
album=CCC
track gain: -7.09, album gain: -7.09
---------
artist=DDD
title=DDD
album=DDD
track gain: -8.09, album gain: -8.09
---------
artist=EEE
title=EEE
album=EEE
track gain: -18.09, album gain: -18.09
---------
$ ./gain.awk -v x=-8 gain_test.txt 
artist=DDD
title=DDD
album=DDD
track gain: -8.09, album gain: -8.09
---------
artist=EEE
title=EEE
album=EEE
track gain: -18.09, album gain: -18.09
---------
$ ./gain.awk -v x=-20 gain_test.txt 
$
in other words: works here
Hello Vaphell,

Your code is perfect it is my fingers and brain that have the problem. Sorry, sometimes I try to do things too quickly and end up making a mess of things, but anyway your script is working wonderfully here and its very fast as well and outputs just like I need it to. I was fingering this part up: if( tg<x ), I misunderstood what you told me to put there on the last post before So, it's all good now and I thank you profusely with great joy that this is working now Now I have the big job of processing all this music.

Cheers Vaphell and Thanks Again,

Singtoh