# Importing values from generated XML file to matching tracks

**URL:** https://community.mp3tag.de/t/importing-values-from-generated-xml-file-to-matching-tracks/17674
**Category:** Support
**Created:** [February 22, 2016, 3:46am UTC](https://community.mp3tag.de/t/importing-values-from-generated-xml-file-to-matching-tracks/17674 "2016-02-22T03:46:02Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![LaurenBacall](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/35a633/32.png) [@LaurenBacall](https://community.mp3tag.de/u/LaurenBacall)
#### Post date: [February 22, 2016, 3:46am UTC](https://community.mp3tag.de/t/importing-values-from-generated-xml-file-to-matching-tracks/17674/1 "2016-02-22T03:46:02Z")

</div>

So I've been applying ReplayGain using foobar2000 to most of the recent music I've purchased, and have been looking into applying it to older albums, too.

However I dislike the way it modifies the Date Modified timestamps, since I use the Mp3Tag option to preserve the original timestamps and would like ReplayGain tags to be treated similarly.

Thus started my exploring alternative options using Mp3Tag and CLI tools 😉

So I found a command-line ReplayGain scanning program called [BS1770GAIN](http://bs1770gain.sourceforge.net/) over on Sourceforge that allows you to import from a file/directory and output ReplayGain results to file.

1. I use the following command to scan a directory, from a custom Mp3Tag Tools context menu item:

```
bs1770gain "$cutRight(%_workingpath%,1)" --replaygain -p --unit db --xml -f "C:\Users\LaurenBacall\AppData\Local\Temp\RG-Results.xml"

```

This sets ReplayGain as the type of scan, units as dB, and output format as XML. Also placed it in a consistent temp directory so I don't have to delete any left-over files later. The $cutRight() function is used since the program doesn't like the trailing backslash.

2. I then import that file into a custom tag on all the selected files using an 'Import from File' action.

It's here that I'm stuck. Since I need the whole directory to be scanned to get the Album Peak and Album Gain results all the tracks are listed in the _RG-Results.xml_ output file, with the Album Peak/Gain values listed at the end. What can be done to match the individual files and values in the XML to those selected in Mp3Tag and apply them as tags?

Example output from the file:

```
<bs1770gain>
  <album folder="Test">
	<track total="12" number="1" file="Todd Terje - It's Album Time - 01 - Intro (It's Album Time).flac">
	  <integrated lufs="-13.14" lu="-4.86" />
	  <sample-peak spfs="-0.14" factor="0.983947" />
	</track>
	<track total="12" number="2" file="Todd Terje - It's Album Time - 02 - Leisure Suit Preben.flac">
	  <integrated lufs="-11.07" lu="-6.93" />
	  <sample-peak spfs="-0.14" factor="0.984466" />
	</track>
	<track total="12" number="3" file="Todd Terje - It's Album Time - 03 - Preben Goes To Acapulco.flac">
	  <integrated lufs="-12.31" lu="-5.69" />
	  <sample-peak spfs="-0.14" factor="0.984100" />
	</track>
	<track total="12" number="4" file="Todd Terje - It's Album Time - 04 - Svensk Sås.flac">
	  <integrated lufs="-13.46" lu="-4.54" />
	  <sample-peak spfs="-0.14" factor="0.983764" />
	</track>
	<track total="12" number="5" file="Todd Terje - It's Album Time - 05 - Strandbar.flac">
	  <integrated lufs="-12.26" lu="-5.74" />
	  <sample-peak spfs="-0.14" factor="0.984283" />
	</track>
	<track total="12" number="6" file="Todd Terje - It's Album Time - 06 - Delorian Dynamite.flac">
	  <integrated lufs="-12.32" lu="-5.68" />
	  <sample-peak spfs="-0.15" factor="0.982971" />
	</track>
	<track total="12" number="7" file="Todd Terje - It's Album Time - 07 - Johnny and Mary (feat. Bryan Ferry).flac">
	  <integrated lufs="-11.32" lu="-6.68" />
	  <sample-peak spfs="-0.15" factor="0.983306" />
	</track>
	<track total="12" number="8" file="Todd Terje - It's Album Time - 08 - Alfonso Muskedunder.flac">
	  <integrated lufs="-9.95" lu="-8.05" />
	  <sample-peak spfs="-0.14" factor="0.983795" />
	</track>
	<track total="12" number="9" file="Todd Terje - It's Album Time - 09 - Swing Star (Part I).flac">
	  <integrated lufs="-13.74" lu="-4.26" />
	  <sample-peak spfs="-0.14" factor="0.983489" />
	</track>
	<track total="12" number="10" file="Todd Terje - It's Album Time - 10 - Swing Star (Part II).flac">
	  <integrated lufs="-13.45" lu="-4.55" />
	  <sample-peak spfs="-0.14" factor="0.983703" />
	</track>
	<track total="12" number="11" file="Todd Terje - It's Album Time - 11 - Oh Joy.flac">
	  <integrated lufs="-13.73" lu="-4.27" />
	  <sample-peak spfs="-0.13" factor="0.985412" />
	</track>
	<track total="12" number="12" file="Todd Terje - It's Album Time - 12 - Inspector Norse.flac">
	  <integrated lufs="-12.03" lu="-5.97" />
	  <sample-peak spfs="-0.14" factor="0.983947" />
	</track>
	<summary total="12">
	  <integrated lufs="-12.24" lu="-5.76" />
	  <sample-peak spfs="-0.13" factor="0.985412" />
	</summary>
  </album>
</bs1770gain>

```

And the ReplayGain values extracted from the above:

_Album Gain:_

#

```
<integrated lufs="-12.24" lu="<b>-5.76</b>" />
<sample-peak spfs="-0.13" factor="0.985412" />

```

_Album Peak:_

#

```
<integrated lufs="-12.24" lu="-5.76" />
<sample-peak spfs="-0.13" factor="<b>0.985412</b>" />

```

_Track Gain (for track #01):_

 

```
<integrated lufs="-13.14" lu="<b>-4.86</b>" />
<sample-peak spfs="-0.14" factor="0.983947" />

```

 

_Track Peak (for track #01):_

 

```
<integrated lufs="-13.14" lu="-4.86" />
<sample-peak spfs="-0.14" factor="<b>0.983947</b>" />

```

---

_[View the full topic](https://community.mp3tag.de/t/importing-values-from-generated-xml-file-to-matching-tracks/17674)._
