# \[X\] FORMAT statements step on each other, corrupting results

**URL:** https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122
**Category:** No Bugs
**Created:** [August 3, 2015, 3:10pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122 "2015-08-03T15:10:49Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [August 3, 2015, 3:10pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/1 "2015-08-03T15:10:49Z")

</div>

I have a FORMAT statement that cuts lengthy titles to a maximum length at the closest word break, but only if the title is too long (i.e., I don't want to slowly eat away at the title each time I run the action). Action #1 below works just fine for this, but not if it comes after Action #0.

Here's the Action Group = test.mta

[#0]  
T=5  
F=TITLE  
1=$if($eql(%album%,'Any Other Album'),$regexp(%title%,'\\d+',),%title%)

[#1]  
T=5  
F=TITLE  
1=$if($eql(%album%,'The John Batchelor Show'),$if($grtr($len(%title%),20),$regexp($left(%title%,20),'\\s[^\\s]\*$',),%title%),%title%)

#1 stops working in the above .mta, but if you change \\d+ to \\d in #0 then #1 works just fine. Alternately you can flip the order of #1 and #0 and #1 will work.  
The syntax of #0 and #1 are both correct, and work fine when used alone. Together #0 breaks #1.

This was tested with a fresh install of the latest version of Mp3tag.

[test.mp3](https://community.mp3tag.de/uploads/default/original/2X/2/2502a056a19772b0ff3c4b5735028ee818bd8459.mp3) (8.79 KB)

[test.mta](https://community.mp3tag.de/uploads/default/original/2X/c/cb9900748f5c9bdd166163f7a4374dd742c0972a.mta) (251 Bytes)

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [August 3, 2015, 3:21pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/2 "2015-08-03T15:21:19Z")

</div>

> [@rko31415](#):
>
> ...$regexp(%title%,'\\d+',),%title%)..

I am rather puzzled about the \\d as this masks the \ so that you do not really look for a number.  
What is that supposed

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [August 3, 2015, 4:03pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/3 "2015-08-03T16:03:12Z")

</div>

> [@ohrenkino](#):
>
> I am rather puzzled about the \\d as this masks the \ so that you do not really look for a number.What is that supposed

It is the escaped code from inner mta file.  
We rarely communicate on this way.

DD.20150803.2003.CEST

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [August 3, 2015, 4:19pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/4 "2015-08-03T16:19:04Z")

</div>

> [@rko31415](#):
>
> ... Here's the Action Group = test.mta  
> [#0]  
> T=5  
> F=TITLE  
> 1=$if($eql(%album%,'Any Other Album'),$regexp(%title%,'\\d+',),%title%)

The regular expression works this way ...

**$regexp(%TITLE%,'\d+',) "This is 1 test of 99 tests in 123 files." -\> "This is test of tests in files."**

This works fine ...

**$if($grtr($len(%TITLE%),20),$regexp($left(%TITLE%,20),'\s[^\s]\*$',),%TITLE%) $ifgreater($len(%TITLE%),20,$regexp($left(%TITLE%,20),'\s[^\s]\*$',),%TITLE%) "This is 1 test of 123 tests in 99 files" -\> "This is 1 test of"**

Which meaning does the if-clauses have?

**$if($eql(%ALBUM%,'Any Other Album'), ... $if($eql(%ALBUM%,'The John Batchelor Show'), ...**

What does this mean in practice?  
"#1 stops working in the above .mta"

This works fine ...

**Begin Action Group 20150803.Test.rko Action #1 Actiontype 5: Format value Field \_\_\_\_\_\_: TITLE Formatstring: $if($eql(%ALBUM%,'Any Other Album'),$regexp(%TITLE%,'\d+',),%TITLE%) Action #2 Actiontype 5: Format value Field \_\_\_\_\_\_: TITLE Formatstring: $if($eql(%ALBUM%,'The John Batchelor Show'),$ifgreater($len(%TITLE%),20,$regexp($left(%TITLE%,20),'\s[^\s]\*$',),%TITLE%),%TITLE%) End Action Group 20150803.Test.rko (2 Actions)****File 1: ALBUM='Any Other Album' TITLE= ... "This is 1 test of 99 tests in 123 files." -\> "This is test of tests in files." File 2: ALBUM='The John Batchelor Show' TITLE= ... "This is 1 test of 99 tests in 123 files." -\> "This is 1 test of" File 3: ALBUM='Album' TITLE= ... "This is 1 test of 99 tests in 123 files." -\> "This is 1 test of 99 tests in 123 files."**

The results are always the same regardless of any order of the three files.

**There is no justification for a bug report.**

The MTA file ...

**ï»¿[#0]**

T=5  
F=TITLE  
1=$if($eql(%ALBUM%,'Any Other Album'),$regexp(%TITLE%,'\\d+',),%TITLE%)

 

**[#1]  
T=5  
F=TITLE  
1=$if($eql(%ALBUM%,'The John Batchelor Show'),$ifgreater($len(%TITLE%),20,$regexp($left(%TITLE%,20),'\\s[^\\s]\*$',),%TITLE%),%TITLE%)**

 

[20150803.Test.rko.mta](https://community.mp3tag.de/uploads/default/original/2X/c/cbaf18d34489785d982c3e11b06396bcb500f890.mta) (255 Bytes)

 

DD.20150803.2126.CEST

 

[20150803.Test.rko.mta](https://community.mp3tag.de/uploads/default/original/2X/c/cbaf18d34489785d982c3e11b06396bcb500f890.mta) (255 Bytes)

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [August 3, 2015, 4:46pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/5 "2015-08-03T16:46:32Z")

</div>

> [@DetlevD](#):
>
> The regular expression works this way ...
> 
> Yes I know. I simplified a more complex regex just for purposes of this bug report. In case you're interested here's the original regex (one of many different regexp that cause the same bug).  
> $if($eql(%album%,'Best of Natural History Radio'),$regexp(%title%,'^\d+ (?i)(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) \d+',),%title%)
> 
> Which meaning does the if-clauses have?
> 
> I have unique edits for each album. Each podcast publisher has their own screwy way of formatting tags, and I harmonize them to a standard format. The if-clause ensures edits for one album don't slop over into another. I have hundreds of albums, each with unique editing criteria built up over the years.
> 
> What does this mean in practice?
> 
> The FORMAT statement at #1 is used to clean up the album "The John Batchelor Show", which I just started listening to (pretty good Book Author interviews). I inserted into the Action Group the FORMAT statement for this album alphabetically and noticed it didn't work. So I tried the FORMAT statement by itself and it worked. Then by the process of elimination I found the reason it didn't work alphabetically. That is, an earlier action interfered with its action.
> 
> DD.20150803.2026.CEST

Hence the bug report.

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [August 3, 2015, 6:39pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/6 "2015-08-03T18:39:51Z")

</div>

Sorry for last post. I missed the subtle difference you made in the formulas.

I used: $if($grtr($len(%title%),20)  
You used: $ifgreater($len(%TITLE%),20

Yours worked, mine didn't.

I'm okay with that. I'll just have to remember not to use $grtr in FORMAT statements from now on.

rko

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [August 3, 2015, 6:53pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/7 "2015-08-03T18:53:27Z")

</div>

> [@rko31415](#):
>
> Sorry for last post. I missed the subtle difference you made in the formulas. ...

Just to make sure ...

**Action "Format value" Tag-Field ..: TEST Formatstring: $if($grtr($len('1234'),3),'is greater','is not greater') ==\> 'is greater' ... or ... Formatstring: $if($grtr($len('1234'),4),'is greater','is not greater') ==\> 'is not greater' ... or ... Formatstring: $ifgreater($len('1234'),3,'is greater','is not greater') ==\> 'is greater' ... or ... Formatstring: $ifgreater($len('1234'),4,'is greater','is not greater') ==\> 'is not greater'**

DD.20150803.2253.CEST

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [December 28, 2018, 2:36pm UTC](https://community.mp3tag.de/t/x-format-statements-step-on-each-other-corrupting-results/17122/8 "2018-12-28T14:36:17Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
