# Re-numbering tracks

**URL:** <https://community.mp3tag.de/t/re-numbering-tracks/17074>\
**Category:** Support\
**Created:** [July 20, 2015, 12:37pm UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074 "2015-07-20T12:37:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [July 20, 2015, 12:37pm UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/1 "2015-07-20T12:37:14Z")

</div>

I would like to know, how to in one easy step change a number to a higher / lower. Can it be done with an action?

Example:

**BEFORE**

Song A has TRACK tag 3  
Song B has TRACK tag 25  
Song C has TRACK tag 100  
Song D has TRACK tag 2-3  
Song E has TRACK tag 9-20  
Song F has TRACK tag 50-100

**AFTER [GOING UP]**

Song A has TRACK tag 4  
Song B has TRACK tag 26  
Song C has TRACK tag 101  
Song D has TRACK tag 3-4  
Song E has TRACK tag 10-21  
Song F has TRACK tag 51-101

**AFTER [GOING DOWN]**

Song A has TRACK tag 2  
Song B has TRACK tag 24  
Song C has TRACK tag 99  
Song D has TRACK tag 1-2  
Song E has TRACK tag 8-19  
Song F has TRACK tag 49-99

[As I understand, the Autonumbering Wizard cannot deal with this]

---

<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:** [July 20, 2015, 1:03pm UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/2 "2015-07-20T13:03:35Z")

</div>

> [@zerow](#):
>
> I would like to know, how to in one easy step change a number to a higher / lower. Can it be done with an action? ...

In general ...

- count up  
TRACK \<== $add(%TRACK%,1)
- count down  
TRACK \<== $sub(%TRACK%,1)

DD.20150720.1703.CEST

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [July 20, 2015, 6:10pm UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/3 "2015-07-20T18:10:15Z")

</div>

> [@DetlevD](#):
>
> In general ...
> 
> - count up  
> TRACK \<== $add(%TRACK%,1)
> - count down  
> TRACK \<== $sub(%TRACK%,1)
> 
> DD.20150720.1703.CEST

Thank you very much for direct me in the right way

This is what I came up with [with differences bolded out]

FOR [GOING UP](http://sendfile.pl/pokaz/431774---KgbT.html):

Format value "TRACK": %TRACK%-  
Guss values "%TRACK%": %TRACK\_TEMP\_1%-%TRACK\_TEMP\_2%  
Format value "TRACK\_TEMP-1": $ **add** (%TRACK\_TEMP\_1%,1)  
Format value "TRACK\_TEMP-2": $ **add** (%TRACK\_TEMP\_2%,1)  
Format value "TRACK": %TRACK\_TEMP\_1% -%TRACK\_TEMP\_2%  
Replace "TRACK": " **-1**" -\> "" (only as a whole word)  
Replace "TRACK": " " -\> ""  
Format value "TRACK\_TEMP\_1": $char(0)  
Format value "TRACK\_TEMP\_2": $char(0)

FOR [GOING DOWN](http://sendfile.pl/pokaz/431771---kSg2.html):

Format value "TRACK": %TRACK%-  
Guss values "%TRACK%": %TRACK\_TEMP\_1%-%TRACK\_TEMP\_2%  
Format value "TRACK\_TEMP-1": $ **sub** (%TRACK\_TEMP\_1%,1)  
Format value "TRACK\_TEMP-2": $ **sub** (%TRACK\_TEMP\_2%,1)  
Format value "TRACK": %TRACK\_TEMP\_1% -%TRACK\_TEMP\_2%  
Replace "TRACK": " **--1**" -\> "" (only as a whole word)  
Replace "TRACK": " " -\> ""  
Format value "TRACK\_TEMP\_1": $char(0)  
Format value "TRACK\_TEMP\_2": $char(0)

And so it works both for single numbers and for ranged ones [those written with a \>\>-\<\< between them]

But there is one thing this action group of mine does not cover: sometimes I use \>\>~~\<\< and \>\>.\<\< in TRACK field for some specific purpose. Although this code is not to be used files with such special values, it should have a safety lines build in it [in case I accidentally use run it on such special files]

So what I lack now is a way to tell it [at the very beginning] to copy "~~" or "." [if they is such value] to third temporary field; so that it can be copied back to the TRACK field [if such value exist in this third temporary field]

How do I do that [the beginning part]?

---

<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:** [July 21, 2015, 6:12am UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/4 "2015-07-21T06:12:58Z")

</div>

> [@zerow](#):
>
> ... sometimes I use \>\>~~\<\< and \>\>.\<\< in TRACK field for some specific purpose. Although this code is not to be used files with such special values, it should have a safety lines build in it [in case I accidentally use run it on such special files]  
> So what I lack now is a way to tell it [at the very beginning] to copy "~~" or "." [if they is such value] to third temporary field; so that it can be copied back to the TRACK field [if such value exist in this third temporary field] How do I do that [the beginning part]?

How to detect "~~" or "." in a string? Use function $strstr() or $strchr().

TRACK\_SAVE \<== $ifgreater($strstr(%TRACK%,'~~'),0,%TRACK%,)  
TRACK\_SAVE \<== $ifgreater($strchr(%TRACK%,'.'),0,%TRACK%,%TRACK\_SAVE%)

DD.20150721.1012.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:** [July 21, 2015, 7:39am UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/5 "2015-07-21T07:39:06Z")

</div>

> [@zerow](#):
>
> ... GOING UP ... GOING DOWN ... And so it works both for single numbers and for ranged ones [those written with a \>\>-\<\< between them] ...

Thank you for the idea, ... I have taken the liberty for small changes ... not thoroughly tested yet..

Begin Action Group **Format &TRACK#&r Set TRACK count +1** 

Action #1  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format \_\_:_ **%TRACK%'-'**  
_Guessing pattern:_ **%TRACK\_TEMP1%-%TRACK\_TEMP2%**

 

Action #2  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TRACK\_TEMP1**  
_Formatstring:_ **$add(%TRACK\_TEMP1%,1)**

 

Action #3  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TRACK\_TEMP2**  
_Formatstring:_ **[$add(%TRACK\_TEMP2%,1)]**

 

Action #4  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TRACK**  
_Formatstring:_ **%TRACK\_TEMP1%['-'%TRACK\_TEMP2%]**

 

Action #5  
_Actiontype 9:_ **Remove fields**  
_Fields to remove (semicolon separated):_ **TRACK\_TEMP1;TRACK\_TEMP2**

 

End Action Group **Format &TRACK#&r Set TRACK count +1** (5 Actions)

 Begin Action Group **Format &TRACK#&s Set TRACK count -1** 

Action #1  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format \_\_:_ **%TRACK%'-'**  
_Guessing pattern:_ **%TRACK\_TEMP1%-%TRACK\_TEMP2%**

 

Action #2  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TRACK\_TEMP1**  
_Formatstring:_ **$sub(%TRACK\_TEMP1%,1)**

 

Action #3  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TRACK\_TEMP2**  
_Formatstring:_ **[$sub(%TRACK\_TEMP2%,1)]**

 

Action #4  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TRACK**  
_Formatstring:_ **$ifgreater(%TRACK\_TEMP1%,0,%TRACK\_TEMP1%['-'%TRACK\_TEMP2%],)**

 

Action #5  
_Actiontype 9:_ **Remove fields**  
_Fields to remove (semicolon separated):_ **TRACK\_TEMP1;TRACK\_TEMP2**

 

End Action Group **Format &TRACK#&s Set TRACK count -1** (5 Actions)

 

[Format\_\_TRACK\_\_r\_\_\_\_\_\_Set\_TRACK\_count\_\_1.mta](https://community.mp3tag.de/uploads/default/original/2X/d/d2009d4e5c0067060b7784e4a3ce189433bf8042.mta) (266 Bytes)[Format\_\_TRACK\_\_s\_\_\_\_\_\_Set\_TRACK\_count\_\_1.mta](https://community.mp3tag.de/uploads/default/original/2X/7/7f2c77d840a59d49c8ff38b39001d8e426bddd3c.mta) (295 Bytes)

 

DD.20150721.1139.CEST

 

[Format\_\_TRACK\_\_r\_\_\_\_\_\_Set\_TRACK\_count\_\_1.mta](https://community.mp3tag.de/uploads/default/original/2X/d/d2009d4e5c0067060b7784e4a3ce189433bf8042.mta) (266 Bytes)

 

[Format\_\_TRACK\_\_s\_\_\_\_\_\_Set\_TRACK\_count\_\_1.mta](https://community.mp3tag.de/uploads/default/original/2X/7/7f2c77d840a59d49c8ff38b39001d8e426bddd3c.mta) (295 Bytes)

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [July 21, 2015, 7:59am UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/6 "2015-07-21T07:59:56Z")

</div>

> [@DetlevD](#):
>
> How to detect "~~" or "." in a string? Use function $strstr() or $strchr().
> 
> TRACK\_SAVE \<== $ifgreater($strstr(%TRACK%,'~~'),0,%TRACK%,)  
> TRACK\_SAVE \<== $ifgreater($strchr(%TRACK%,'.'),0,%TRACK%,%TRACK\_SAVE%)
> 
> DD.20150721.1012.CEST

OK

For my system / nomenclature this now sums up to a [**new** version](http://sendfile.es/pokaz/432705---iUsK.html) like this [for going up]

**Format value "TEMPORARY": $char(0)  
Format value "TEMPORARY": $ifgreater($strchr(%TRACK%,'.'),0,%TRACK%,%TEMPORARY%)  
Format value "TEMPORARY": $ifgreater($strchr(%TRACK%,'~~'),0,%TRACK%,%TEMPORARY%)  
Format value "TEMPORARY": $ifgreater($strchr(%TRACK%,'X'),0,%TRACK%,%TEMPORARY%)  
Format value "TEMPORARY": $ifgreater($strchr(%TRACK%,'X-Y'),0,%TRACK%,%TEMPORARY%)**  
Format value "TRACK": %TRACK%-  
Guss values "%TRACK%": %TRACK\_TEMP\_1%-%TRACK\_TEMP\_2%  
Format value "TRACK\_TEMP-1": $add(%TRACK\_TEMP\_1%,1)  
Format value "TRACK\_TEMP-2": $add(%TRACK\_TEMP\_2%,1)  
Format value "TRACK": %TRACK\_TEMP\_1% -%TRACK\_TEMP\_2%  
Replace "TRACK": "-1" -\> "" (only as a whole word)  
Replace "TRACK": " " -\> ""  
Format value "TRACK\_TEMP\_1": $char(0)  
Format value "TRACK\_TEMP\_2": $char(0)  
**Replace "TRACK": $if2(%TEMPORARY%,%TRACK%)  
Format value "TEMPORARY": $char(0)**

Eventually: could the line for one of each of the four of unusual cases [\>\>.\<\<, \>\>~~\<\< \>\>X\<\<, \>\>X-Y\<\<] be replaced by one common, that would say something like: if it is no a digit, then copy it to the TEMPORARY?

I fear that in future I may in my system change for example "X-Y" to something else and simply forget to adjust this particular code on behalf of that change. And if the code would not have a list but overall instruction then this error would not show up then

---

<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:** [July 21, 2015, 8:21am UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/7 "2015-07-21T08:21:15Z")

</div>

> [@zerow](#):
>
> For my system / nomenclature ...

Note: $strstr() instead of $strchr() will work too for single character.

DD.20150721.1221.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:** [July 21, 2015, 8:28am UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/8 "2015-07-21T08:28:32Z")

</div>

> [@zerow](#):
>
> ... Eventually: could the line for one of each of the four of unusual cases [\>\>.\<\<, \>\>~~\<\< \>\>X\<\<, \>\>X-Y\<\<] be replaced by one common, that would say something like: if it is no a digit, then copy it to the TEMPORARY? ...

Just a quick idea ...  
Remove all digits from the tagfield TRACK ...  
$regexp(%TRACK%,'\d',)  
... if the remaining tagfield is (not) empty, ... then do this, else do that.

$if($eql($regexp(%TRACK%,'\d',),),'good','bad')  
... or ...  
$ifgreater($len($regexp(%TRACK%,'\d',)),0,'bad','good')

... or if the minus hyphen character is allowed ...  
$if($eql($regexp(%TRACK%,'\d|-',),),'good','bad')  
... or ...  
$ifgreater($len($regexp(%TRACK%,'\d|-',)),0,'bad','good')

DD.20150721.1243.CEST

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [July 22, 2015, 10:01am UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/9 "2015-07-22T10:01:11Z")

</div>

> [@DetlevD](#):
>
> Thank you for the idea, ... I have taken the liberty for small changes ... not thoroughly tested yet..
> 
> Begin Action Group **Format &TRACK#&r Set TRACK count +1** 
> 
> Action #1  
> _Actiontype 7:_ **Import tag fields (guess values)**  
> _Source format \_\_:_ **%TRACK%'-'**  
> _Guessing pattern:_ **%TRACK\_TEMP1%-%TRACK\_TEMP2%**
> 
>  
> 
> Action #2  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **TRACK\_TEMP1**  
> _Formatstring:_ **$add(%TRACK\_TEMP1%,1)**
> 
>  
> 
> Action #3  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **TRACK\_TEMP2**  
> _Formatstring:_ **[$add(%TRACK\_TEMP2%,1)]**
> 
>  
> 
> Action #4  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **TRACK**  
> _Formatstring:_ **%TRACK\_TEMP1%['-'%TRACK\_TEMP2%]**
> 
>  
> 
> Action #5  
> _Actiontype 9:_ **Remove fields**  
> _Fields to remove (semicolon separated):_ **TRACK\_TEMP1;TRACK\_TEMP2**
> 
>  
> 
> End Action Group **Format &TRACK#&r Set TRACK count +1** (5 Actions)
> 
> Begin Action Group **Format &TRACK#&s Set TRACK count -1** 
> 
> Action #1  
> _Actiontype 7:_ **Import tag fields (guess values)**  
> _Source format \_\_:_ **%TRACK%'-'**  
> _Guessing pattern:_ **%TRACK\_TEMP1%-%TRACK\_TEMP2%**
> 
>  
> 
> Action #2  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **TRACK\_TEMP1**  
> _Formatstring:_ **$sub(%TRACK\_TEMP1%,1)**
> 
>  
> 
> Action #3  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **TRACK\_TEMP2**  
> _Formatstring:_ **[$sub(%TRACK\_TEMP2%,1)]**
> 
>  
> 
> Action #4  
> _Actiontype 5:_ **Format value**  
> _Field \_\_\_\_\_\_:_ **TRACK**  
> _Formatstring:_ **$ifgreater(%TRACK\_TEMP1%,0,%TRACK\_TEMP1%['-'%TRACK\_TEMP2%],)**
> 
>  
> 
> Action #5  
> _Actiontype 9:_ **Remove fields**  
> _Fields to remove (semicolon separated):_ **TRACK\_TEMP1;TRACK\_TEMP2**
> 
>  
> 
> End Action Group **Format &TRACK#&s Set TRACK count -1** (5 Actions)  
> DD.20150721.1139.CEST

They seem to work fine for both 0  
and 0-0format

But they do not cover the

```
~~.
X
X-Ycases; but with that I have dealt with already

```

---

<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:25pm UTC](https://community.mp3tag.de/t/re-numbering-tracks/17074/10 "2026-02-09T12:25:46Z")

</div>

Closed on February 9, 2026, 12:25pm UTC


