Converting MP3 Gain values to iTunes format

Hello all. Have to say that since ditching Tag&Rename in favour of mp3Tag, I am one super happy camper. This app rocks! I especially like being able to customize the tag panel to display whatever I want.

So here is what I need some help with. I have a majority of mp3s that are "singles" or "orphans" as I call them that do not belong to an album because I only like that song and discard the rest of the songs on the album. When I scanned my mp3s with foobar the files I had scanned them separately from the 'album' files and applied a per-file normalization at 91db. Foobar created only two additional tags for these files; REPLAYGAIN_TRACK_GAIN and REPLAYGAIN_TRACK_PEAK. Conversely, when I scanned the rest of the mp3s and applied 'Scan selection by Album (by tags)' it created four new tags; REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK, REPLAYGAIN_ALBUM_GAIN, and REPLAYGAIN_ALBUM_PEAK.

I'd like to convert the tags for iTunes to read now and I'd like help with a regex to do it. I searched and found the action below. What I'd like to be able to do is add a variable to the string below. It would be ideal to have the script recognize if the file has the REPLAYGAIN_TRACK_GAIN value and convert it to the iTunes format ONLY if REPLAYGAIN_ALBUM_GAIN is not present. Any help with this will be greatly appreciated.

Format value.  
Format Value: $rg2sc(%REPLAYGAIN_TRACK_GAIN%)

I know that one option is loading all my files and creating a column to isolate the files from one another it's just that this way I can learn more about regex's...


  1. That's not a regex.

  2. Try

This format string checks if REPLAYGAIN_ALBUM_GAIN exists and if positive deletes the itunnorm field. Otherwise $rg2sc(%REPLAYGAIN_TRACK_GAIN%) is used.

Okay that gets me on the right track. I tweaked it a bit. This way it checks to see if ALBUMGAIN exists, if it does than it converts to ITUNNORM. If ALBUMGAIN does not exist, it uses the TRACKGAIN value and converts that to ITUNNORM.


The only side-effect using this was if if I mistakenly selected a file without any replaygain values, it processes the blank field and converts it to look like this:

000003E8 000003E8 000003E8 000003E8 000003E8 000003E8 000003E8 000003E8 000003E8 000003E8

I created a regex that searches for that string and replaces it with nothing.

Thanks again!!!

Well we can make a string that works without this side effect

I saw you posted your findings in the regular expression thread. Unfortunately that's not the right place. I'll move it later.

Edit: I've moved it here
as it is the same topic.

I hope you update it with the new string.

Thanks. I edited that other post and gave you credit for it. I knew it had something to do with those brackets! I just couldn't get it to work :slight_smile: