# Automatic Discnumber tag from Directory Structure

**URL:** https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395
**Category:** Support
**Created:** [May 6, 2010, 10:48am UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395 "2010-05-06T10:48:39Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Tanku](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@Tanku](https://community.mp3tag.de/u/Tanku)
#### Post date: [May 6, 2010, 10:48am UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/1 "2010-05-06T10:48:39Z")

</div>

Hi guys

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

Problem is I have searched ![:book:](https://community.mp3tag.de/uploads/default/original/1X/0036d5b68f6226c53f6c68abfd0a7b8096fd4505.gif ":book:") high and low and I cannot find a regexp to automatically tag the discnumber from directory structure.

My structure is;

\Artist\Album\Files  
or  
\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

e.g.  
CD1  
CD2  
CD3  
CD4

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

---

<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: [May 6, 2010, 2:19pm UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/2 "2010-05-06T14:19:37Z")

</div>

> [@Tanku](#):
>
> ... I have been using this prog for many years now ... and I cannot find a regexp to automatically tag the discnumber from directory structure. ... Would write each folder as 1/4,2/4,3/4,4/4 and so on. ...

Read through these topics:  
[Generating %DISCNUMBER% Tags](https://community.mp3tag.de/t/4117/1)  
[Discnumber Action](https://community.mp3tag.de/t/5793/1)  
[Settgin disc qty from folder qty](https://community.mp3tag.de/t/6567/1)  
There should be some hints how to do.

DD.20100506.1819.CEST

---

<div class="post-metadata">

### Author: ![Tanku](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@Tanku](https://community.mp3tag.de/u/Tanku)
#### Post date: [May 6, 2010, 2:53pm UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/3 "2010-05-06T14:53:28Z")

</div>

_Begin Actionsgroup Set DISCNUMBER n.3  
Action #1  
Actiontype 5: Format tag field  
Field: DISCNUMBER  
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 😃

Thanks

---

<div class="post-metadata">

### Author: ![Tanku](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@Tanku](https://community.mp3tag.de/u/Tanku)
#### Post date: [May 6, 2010, 3:04pm UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/4 "2010-05-06T15:04:19Z")

</div>

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?

thanks

---

<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: [May 6, 2010, 3:20pm UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/5 "2010-05-06T15:20:32Z")

</div>

> [@Tanku](#):
>
> ... I spoke too soon! Not automatically. ... The codes in the links you have provided are manual. ...

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.

DD.20100506.1919.CEST

---

<div class="post-metadata">

### Author: ![Tanku](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/e0b2c6/32.png) [@Tanku](https://community.mp3tag.de/u/Tanku)
#### Post date: [May 10, 2010, 11:14am UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/6 "2010-05-10T11:14:27Z")

</div>

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?

Thanks

---

<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: [May 10, 2010, 12:12pm UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/7 "2010-05-10T12:12:15Z")

</div>

> [@Tanku](#):
>
> I dont have the slightest idea as how the export scripts can count the folders? ...

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.

DD.20100510.1610.CEST

---

<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:22pm UTC](https://community.mp3tag.de/t/automatic-discnumber-tag-from-directory-structure/10395/8 "2026-02-09T12:22:22Z")

</div>


