Re-numbering tracks

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]

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:

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:

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]?

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

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 (266 Bytes)Format__TRACK__s______Set_TRACK_count__1.mta (295 Bytes)

DD.20150721.1139.CEST

Format__TRACK__r______Set_TRACK_count__1.mta (266 Bytes)

Format__TRACK__s______Set_TRACK_count__1.mta (295 Bytes)

OK

For my system / nomenclature this now sums up to a new version 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

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

DD.20150721.1221.CEST

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

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