# Generating %DISCNUMBER% Tags

**URL:** https://community.mp3tag.de/t/generating-discnumber-tags/4117
**Category:** Support
**Created:** [November 28, 2006, 2:05pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117 "2006-11-28T14:05:05Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 26, 2007, 8:39pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/21 "2007-11-26T20:39:04Z")

</div>

> [...to count discs...] we need an extra storage place to hold a user defined value while  
> an action runs against the selected tracks

Since then, Mp3tag as acquired actions for Export and Import. So perhaps a solution is: an Export action counts the discs and writes the results to a text file, and then a Import Text File action does a lookup to write them into the tags.

Though this would not work before the fix to the bug at [/t/5799/1](https://community.mp3tag.de/t/5799/1) .

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [November 26, 2007, 8:55pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/22 "2007-11-26T20:55:55Z")

</div>

Actually, import\export did exist when we came to this solution, however we were looking for something that could be done without text files.

Thanks for the input though.

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 26, 2007, 9:29pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/23 "2007-11-26T21:29:55Z")

</div>

> import\export did exist when we came to this solution

Oops! Sorry.

> we were looking for something that could be done without text files.

May I ask why?

---

<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: [November 26, 2007, 9:58pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/24 "2007-11-26T21:58:23Z")

</div>

> [@chrisjj](#):
>
> > [...to count discs...] we need an extra storage place to hold a user defined value while  
> > an action runs against the selected tracks  
> > Since then, Mp3tag as acquired actions for Export and Import. So perhaps a solution is: an Export action counts the discs and writes the results to a text file, and then a Import Text File action does a lookup to write them into the tags.  
> > Though this would not work before the fix to the bug at [/t/5799/1](https://community.mp3tag.de/t/5799/1) .

Yet I didn't tested the new export/import actions in full scope. Today I thought about the discnumber problem of this thread can be solved by export/import action.  
I was in great hope that export/import actions can be used as a temporary storage while running a stream of actions, but we have to realize that the export/import actions are not so powerful and flexible like the other actions. Now we have to find a new workaround for this upcoming new Mp3tag design glitch. That's a pity.

DD.20071126.2357.CET

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 26, 2007, 10:17pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/25 "2007-11-26T22:17:29Z")

</div>

Florian will surely be unable to resist the urge to allow Export first! This will unleash the power of scripting for action data!

If we then also had Action Tagfile - Tag it would permit very neat solutions to two-pass problems such as tagging disc quantity and track quantity, plsu album keying and more exotic things like Album Artist deduction.

Florian, if you would consider this, please also add a %tempfilepath% placeholder, to allow Export and Import to link up without deployment problems. Simple %tempfolderpath% would be incompatible with possible future multiple instances.

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [November 27, 2007, 12:02am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/26 "2007-11-27T00:02:42Z")

</div>

The export method is a roundabout way to solve the problem, what we really need is a internal placeholder.

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 27, 2007, 12:27am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/27 "2007-11-27T00:27:38Z")

</div>

> [@Logan](#):
>
> The export method is a roundabout way to solve the problem, what we really need is a internal placeholder.

I see no overlap. What problem is it that Export solves roundabout but an internal placeholder solves better?

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [November 27, 2007, 1:30am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/28 "2007-11-27T01:30:51Z")

</div>

> [@chrisjj](#):
>
> I see no overlap. What problem is it that Export solves roundabout but an internal placeholder solves better?

Why go outside the app and interface with the filesystem when you can accomplish your goal inside the app?

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 27, 2007, 1:33am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/29 "2007-11-27T01:33:34Z")

</div>

What goal is it that you can accomplish with an internal placeholder?

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [November 27, 2007, 1:37am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/30 "2007-11-27T01:37:16Z")

</div>

In this specific situation, keeping a running count of discs for a specific album so that you can go back and populate 'm' in disc n of m.

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 27, 2007, 1:49am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/31 "2007-11-27T01:49:29Z")

</div>

Well, I don't see how you are going to go back and populate anything, since one action group cannot go back.

The only automatic solution I see uses an initial Export to go forward to do the counting, and then subsequent actions to put the count into the tags.

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [November 27, 2007, 2:14am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/32 "2007-11-27T02:14:38Z")

</div>

You would need two actions, one to either set or increment the placeholder and another to read it and set total\_discs.

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 27, 2007, 10:17am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/33 "2007-11-27T10:17:44Z")

</div>

OK, then my answer to

> Why go outside the app and interface with the filesystem when  
> you can accomplish your goal inside the app?

is: to accomplish the goal in a single operation.

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [November 27, 2007, 1:37pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/34 "2007-11-27T13:37:27Z")

</div>

You don't have a single operation, you need to export, then import.

Either method will work, it is just a mattter of opinion as to where it is best accomplished.

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 27, 2007, 2:06pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/35 "2007-11-27T14:06:47Z")

</div>

> You don't have a single operation, you need to export, then import.

The user has a single operation: run an action group. The author has put the Export and Import as multiple actions within the group, no more so that your proposed two-operation method has multiple actions within the group(s)

> Either method will work, it is just a mattter of opinion as to where it is best accomplished.

Agreed. Let's try both!

---

<div class="post-metadata">

### Author: ![Logan](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@Logan](https://community.mp3tag.de/u/Logan)
#### Post date: [November 27, 2007, 2:19pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/36 "2007-11-27T14:19:32Z")

</div>

I've been using the method described within this thread for close to a year now without issue.

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [November 27, 2007, 2:22pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/37 "2007-11-27T14:22:17Z")

</div>

Understood. By "both" I meant... both! 😉

---

<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: [November 27, 2007, 2:23pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/38 "2007-11-27T14:23:32Z")

</div>

I would like to use an export action that can be freely positioned into an actiongroup at multiple places anywhere in the actiongroup where it is needed and should be applied (fileput), each export action with full support of creating a new textfile by default and having an additional option to append output to existing textfile (fileputappend).

As an sideeffect, such an export action can be used as a debugging instrument.

Beside this physical storage attempt, I would like to use one ore more global in memory placeholder/s for counting and other purposes e. g. as a disc counter.  
"Tag format as global constant/variable" or so.

DD.20071127.1622

---

<div class="post-metadata">

### Author: ![chrisp\_uk](https://community.mp3tag.de/user_avatar/community.mp3tag.de/chrisp_uk/32/7761_2.png) [@chrisp\_uk](https://community.mp3tag.de/u/chrisp_uk)
#### Post date: [April 21, 2014, 8:53pm UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/39 "2014-04-21T20:53:33Z")

</div>

> [@DetlevD](#):
>
> So this may work:  
> Action #1:  
> _Action type:_ **Format value**  
> _Field:_ **DISCNUMBER**  
> _Formatstring:_ **$if($eql($regexp(%\_directory%, \*(CD) \*\d+,$1,0),CD),$regexp(%\_directory%, \*CD \*(\d+),$1,0)/2,1/1)**
> 
> DD.20070119.1655

I have modified this code to work on a collection that uses CD1 , Disc 2 etc.

```
[#0]
T=5
F=DISCNUMBER
1=$if($isdigit($regexp(%_directory%,'^.* *(Disc|CD) *0*(\\\\d+).*$','$2',0)),$regexp(%_directory%,'^.* *(Disc|CD) *0*(\\\\d+).*$','$2'.0),%discnumber%)

```

this works nicely BUT if the \_directory begins with a number then the whole directory name is output as the Discnumber

example: \_directory is "50 Cent - Curtis" then discnumber is "50 Cent - Curtis"

I tried to specify that the IF condition must be a numerical value only using

```
$if($eql($regexp(%_directory%,'^.* *(Disc|CD) *0*(\d+).*$','$2',0),^[0-9]$),$regexp(%_directory%,'^.* *(Disc|CD) *0*(\d+).*$','$2',0),%discnumber%)

```

Or the original code modified for CD AND Disc etc.

```
$if($eql($regexp(%_directory%, *(Disc|CD) *\\\\d+,$1,0),'Disc'|'CD'),$regexp(%album%,'^.* *(Disc|CD) *0*(\\\\d+).*$','$2',0),%discnumber%)

```

I couldn't get either of these to work.I think the method is okay but my beginners scripting is in error. could anybody suggest where I am going wrong?

---

<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: [April 22, 2014, 8:55am UTC](https://community.mp3tag.de/t/generating-discnumber-tags/4117/40 "2014-04-22T08:55:02Z")

</div>

> [@chrisp\_uk](#):
>
> I have modified this code to work on a collection that uses CD1 , Disc 2 etc. ... I tried to specify that the IF condition must be a numerical value only using ... I couldn't get either of these to work.I think the method is okay but my beginners scripting is in error. could anybody suggest where I am going wrong?

 **$if($neql($regexp(%\_directory%,'^.\*\s\*(?:Disc|CD)\s\*0\*(\d+).\*$','$1',0),%\_directory%),$regexp(%\_directory%,'^.\*\s\*(?:Disc|CD)\s\*0\*(\d+).\*$','$1',0),%DISCNUMBER%)**

DD.20140422.1255.CEST

Ignore case ... CD, cd, Cd, cD, DISC, disc, Disc and so on ...

 **$if($neql($regexp(%\_directory%,'^.\*\s\*(?:Disc|CD)\s\*0\*(\d+).\*$','$1',1),%\_directory%),$regexp(%\_directory%,'^.\*\s\*(?:Disc|CD)\s\*0\*(\d+).\*$','$1',1),%DISCNUMBER%)**

DD.20140705.1040.CEST

[Previous page](https://community.mp3tag.de/t/generating-discnumber-tags/4117.md?page=1)

[Next page](https://community.mp3tag.de/t/generating-discnumber-tags/4117.md?page=3)
