Automatic Discnumber tag from Directory Structure

Hi guys

I have been using this prog for many years now and got a tidy library.

Problem is I have searched :book: high and low and I cannot find a regexp to automatically tag the discnumber from directory structure.

My structure is;

\Artist\Album\CD1,CD2 ect.. CD5 (in some cases)

So I was wondering if there has been any development to check the folder structure to see..

  • if there is ..\Album\Files then to just write 1/1 to %discnumber%
  • if there is a CD structure to tag up to X amount


Would write each folder as 1/4,2/4,3/4,4/4 and so on.

It would be nice to have this automatically so I can re-tag all of my collection in one go.

If it makes it easier then would I have to rename ..\Album\Files to ..\Album\CD1??

Hope you can help. Thanks

Read through these topics:
Generating %DISCNUMBER% Tags
Discnumber Action
Settgin disc qty from folder qty
There should be some hints how to do.


Begin Actionsgroup Set DISCNUMBER n.3
Action #1
Actiontype 5: Format tag field
Formatstring: $regexp(%_directory%,^.÷CD÷0(\d+).*$,$1)/3
Note: Replace one special character ÷ with one space character.
End Actionsgroup Set DISCNUMBER n.3 (1 Action)

Thats the one !- Searched for such a long time for this, it works a treat.

You are a legend :smiley:


It doesn't actually work I spoke too soon! Not automatically.

I have an action group that standardizes all my tags to my preferences and I would hope to insert just one action for discnumber.

The codes in the links you have provided are manual.

Any thoughts or have I missed something here?


I am not aware of an automatic procedure how to detect upcoming CDn folders of unknown count.

You might be able to write an export script, which counts the folders and creates a text file, which in a following step can create via "text-file to tag" a DISCTOTAL tag field for each track file within an album. Then the DISTOTAL tag field can be used for all other automating purposes.


I dont have the slightest idea as how the export scripts can count the folders?

Could anyone possibly help??

It would be very much appreciated. Im sure im no the only one with this issue?


Read Mp3tag help manual, sections Export and Scripting functions and understand how the functions $loop() and $_counter() and $_max_counter() work.

Because I do not have a ready made export script, I do not know if this approach will work in such a manner to satisfy your needs.

There has been also reported a "half automatical way" to set the DISCTOTAL number.
At first set the filter to isolate the album to work on, which contains multiple CDs, then run an action "Format value" against the selected files to set the tag field DISCTOTAL to the value of the involved number of CDs.
You may prepare some actions, with each defined to set two, three or more CDs, to shorten the process when repeating.