# Converting MP3 Gain values to iTunes format

**URL:** https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056
**Category:** Support
**Created:** [March 7, 2010, 3:01pm UTC](https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056 "2010-03-07T15:01:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jets](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jets](https://community.mp3tag.de/u/jets)
#### Post date: [March 7, 2010, 3:01pm UTC](https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056/1 "2010-03-07T15:01:10Z")

</div>

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.  
Field Name: COMMENT ITUNNORM 
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...

Thanks.

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [March 8, 2010, 1:05pm UTC](https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056/2 "2010-03-08T13:05:37Z")

</div>

1. That's not a regex.

2. Try  
$if(%REPLAYGAIN\_ALBUM\_GAIN%,,$rg2sc(%REPLAYGAIN\_TRACK\_GAIN%))

This format string checks if REPLAYGAIN\_ALBUM\_GAIN exists and if positive deletes the itunnorm field. Otherwise $rg2sc(%REPLAYGAIN\_TRACK\_GAIN%) is used.

---

<div class="post-metadata">

### Author: ![jets](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jets](https://community.mp3tag.de/u/jets)
#### Post date: [March 8, 2010, 2:18pm UTC](https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056/3 "2010-03-08T14:18:19Z")

</div>

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.

$if(%REPLAYGAIN\_ALBUM\_GAIN%,$rg2sc(%REPLAYGAIN\_ALBUM\_GAIN%),$rg2sc(%REPLAYGAIN\_TRACK\_GAIN%))

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!!!

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [March 8, 2010, 3:42pm UTC](https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056/4 "2010-03-08T15:42:09Z")

</div>

Well we can make a string that works without this side effect  
[$rg2sc($if2(%REPLAYGAIN\_ALBUM\_GAIN%,%REPLAYGAIN\_TRACK\_GAIN%))]

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  
[/t/8069/1](https://community.mp3tag.de/t/8069/1)  
as it is the same topic.

I hope you update it with the new string.

---

<div class="post-metadata">

### Author: ![jets](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/b487fb/32.png) [@jets](https://community.mp3tag.de/u/jets)
#### Post date: [March 10, 2010, 6:03pm UTC](https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056/5 "2010-03-10T18:03:05Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:22pm UTC](https://community.mp3tag.de/t/converting-mp3-gain-values-to-itunes-format/10056/6 "2026-02-09T12:22:14Z")

</div>


