Numerate ID variables from tags in simple numbering order

Hello,
I have couple thousands mp3 files with title or artist tags containing only the ID expression. I would like to know if it is possible to create an action that will automatically numerate all ID expressions in simple order.
For example:
Some Artist - ID
Some Artist - ID
Some Artist - ID
Some Artist - ID
to
Some Artist - ID 01
Some Artist - ID 02
Some Artist - ID 03
Some Artist - ID 04

and
ID - Some Title
ID - Some Title
ID - Some Title
ID - Some Title
to
ID 01 - Some Title
ID 02 - Some Title
ID 03 - Some Title
ID 04 - Some Title

I hope my question is understandable.
If there are already threads to answer my question please point me there.
Thank you a lot in advance.

Hi Azmandius, I do not know what you mean by 'ID expression'. If it is really relevant to solve your problem, then please explain.
Mp3tag provides a system counter variable named as %_counter%, which returns a running number, starting from 1 to however much the variable is called.
This variable can be used in the Mp3tag export section as well as in Mp3tag actions.
The Mp3tag scripting function $num(,) can format a number with leading zeroes with parameter set to a width of your wish, or can remove leading zeroes from a number string with parameter set to 1.
The expression $num(%_counter%,2) can create number strings in the format '01' and so forth.

To append just a formatted counter number to an existing tag-field content, for example to the tag-field ARTIST, you have to code this expression ...

%ARTIST%' '$num(%_counter%,2)

... and put this expression into the 'Format string' edit field of an action 'Format value'.

When running such action against a selection of files all tag-fields ARTIST will be changed to the new value.
From:
Some Artist - ID
To:
Some Artist - ID 01
... and so forth.

This method cannot respect album or folder limits.
It is not clear, if your numbering process should affect the "couple thousands mp3" at once, or numbering should start again from 1 for each album or for each disk folder.
Please elaborate.

DD.20111217.1030.CET

The perfect solution would be numbering to start again from 1 for each folder, but it is also OK if numbering will affect all mp3 files at once.

By 'ID expression' i mean that sometimes when i don't know the artist or track title i just fill manually the missing field with the very word ID instead.

p.s. I just tried the format you suggested %ARTIST%' '$num(%_counter%,2) and i noticed that the numbering was applied to all selected files, while i am looking for a solution to apply numbering to only those files where there is the very word ID instead of the real Artist or track Title.

Lets say i have 5 files from Elvis Presley, and because i don't know the title of any of those i just filled their title tag this way:
Elvis Presley (artist field) - ID (the unknown title field)
Elvis Presley (artist field) - ID (the unknown title field)
Elvis Presley (artist field) - ID (the unknown title field)
Elvis Presley (artist field) - ID (the unknown title field)
Elvis Presley (artist field) - ID (the unknown title field)
Now, how do i distinguish those files if i will want to listen to a particular song of those 5? But, if i will mark their titles ID 01, ID 02, ID 03, etc. it will be simple to easily find the favorite song later.

So i am basically telling Mp3tag to apply numbering only to those titles where there is the very word ID.

The numbering problem can be solved with Mp3tag in different ways.
See following proposals, there might be some other ways to go.

Proposal 1.

Mp3tag provides a filter, that can display only those files in the list view, which match the filter criterion.

An appropriate filter expression can be ...
(TITLE MATCHES "^ID") AND (ARTIST MATCHES "ID$")
... which will display only the files with leading string "ID" in the tag-field TITLE and with trailing string "ID" in the tag-field ARTIST.

Step 1.
Set the Mp3tag Filter to the expression ...
(TITLE MATCHES "^ID") AND (ARTIST MATCHES "ID$")

Step 2.
Fill the counter number into the tag-fields TITLE and ARTIST, as you have described.
Create a group of actions with two actions of type "Format Value", so that the action group can be invoked once per file.

Action #1 "Format value"
Field: TITLE
Formatstring: $num(%_counter%,2)' '%TITLE%

Action #2 "Format value"
Field: ARTIST
Formatstring: %ARTIST%' '$num(%_counter%,2)

Note:
This method cannot respect album or folder limits.
If you need numbering starting from 1 for each disk folder, then you have to select the files within a folder manually, and run the action group solely for each folder.

Proposal 2.

Mp3tag provides an Auto-Numbering-Wizard, which can be adjusted to start the numbering from 1 for each folder.
In this process the tag-field TRACK will be set with the current running number.

As long as there is no important value in the existing tag-field TRACK, you can use this tag-field TRACK to prepare the running number as you need it for the later renaming of the tag-fields TITLE and ARTIST.
If the tag-field TRACK already contains some important value, then this value can be saved into a temporary tag-field, and later restored.
Following step list shows the full process.

Step 1.
Set the Mp3tag Filter to the expression ...
(TITLE MATCHES "^ID") AND (ARTIST MATCHES "ID$")

Step 2.
Select all the files to work on.

Step 3.
Save existing TRACK value into temporary tag-field.

Action "Format value"
Field: TEMP_TRACK
Formatstring: %TRACK%

Step 4.
Adjust the settings of the Auto-Numbering-Wizard and run the autonumbering process against all the files in the selection.
Check the result in the tag-field TRACK.

Step 5.
Run a group of actions with two actions of type "Format Value", so that the action group can be invoked once per file.

Action #1 "Format value"
Field: TITLE
Formatstring: $num(%TRACK%,2)' '%TITLE%

Action #2 "Format value"
Field: ARTIST
Formatstring: %ARTIST%' '$num(%TRACK%,2)

Step 6.
Restore saved TRACK value.

Action "Format value"
Field: TRACK
Formatstring: %TEMP_TRACK%

Step 7.
Remove the temporary tag-field.
Action "Remove tag-fields"
Field: TEMP_TRACK

Proposal 3.

Step 1.
Set the Mp3tag Filter to the expression ...
(TITLE MATCHES "^ID") AND (ARTIST MATCHES "ID$")

Step 2.
Replace all string parts "ID" with the new value "ID' '$num(%_counter%,2)" resp. "ID' '$num(%TRACK%,2)"

Action #1 "Format value"
Field: TITLE
Formatstring: $replace(%TITLE%,'ID -','ID '$num(%_counter%,2)' -')

Action #2 "Format value"
Field: ARTIST
Formatstring: $replace(%ARTIST%,'- ID','- ID '$num(%_counter%,2))

Maybe you find another way?
If so, then please tell us.

DD.20111217.2127.CET

Thank you a lot for detailed reply and tutorial, now i have fulfilled my goal.
Regards.

Should work, see attached picture.



Maybe the content in the tag-fields is somewhat different as you have described.

You may run the attached export script against one file or more and let us see the result report.
20110626.Export.tag.dump.mte (688 Bytes)

DD.20111217.2225.CET


20110626.Export.tag.dump.mte (688 Bytes)

This is exactly the filter i needed:
(TITLE MATCHES "^ID")
&
(ARTIST MATCHES "^ID")
I used the first one and applied the %TITLE%' '$num(%_counter%,2) numeration, then the second. All worked perfectly.
Big thank you DetlevD for help!
Thread solved i guess.

Ah, yes ... you wrote in post #1 ...

> have couple thousands mp3 files with title or artist tags containing only the ID expression.

... therefore the filter expression should be ...

(TITLE MATCHES "^ID") OR (ARTIST MATCHES "ID$")

... to show both cases at once.


I'm glad to hear that all has worked fine for you.

Regards
DD.20111218..0530.CET