# Fixing the tags for multi-disc albums (A01, A02, etc.)

**URL:** https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864
**Category:** General Discussion
**Created:** [February 19, 2018, 4:14am UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864 "2018-02-19T04:14:53Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![tripecac](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tripecac](https://community.mp3tag.de/u/tripecac)
#### Post date: [February 19, 2018, 4:14am UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/1 "2018-02-19T04:14:53Z")

</div>

Hi, I copy all my CDs to my computer and listen to them there. I recently set up a media server to stream my audio files to various devices in my house, but the media server gets confused by the way I've tagged my multi-disc albums.

Using the Beatles' White Album for example, here's how I've been naming files:

A01 Back in the USSR.flac  
A02 Dear Prudence.flac  
...  
A17 Julia.flac  
B01 Birthday.flac  
...

As you can see, I use "A" and B" to indicate which disc. The media server get confused by the non-numeric characters at the start of the filenames.

Users of that media server have recommended that I use mp3tag to set valid track numbers and disc numbers for all of the files.

So, here's what I want:

A01 Back in the USSR.flac -\> disc 1, track 1  
A02 Dear Prudence.flac -\> disc 1, track 2  
B01 Birthday.flac -\> disc 2, track 1

My question is: is it possible for me to get mp3tag to do this?

I have thousands of files to re-tag, and plan to continue to copy CDs to my computer using my current filename scheme (A01, A02, etc. for multi-disc sets), so I would prefer to find a way to automate the tagging rather than doing it manually.

I'm a programmer, so I don't mind writing scripts. I just wanted to know if mp3tag has the flexibility to parse those "A01" type prefixes and add appropriate track and disc numbers.

Thanks!

Travis

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 19, 2018, 5:53am UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/2 "2018-02-19T05:53:41Z")

</div>

Try an action of the type "Guess value"  
Source: $sub($ord($left(%track%,1)),64)==$right(%track%,2)  
Pattern: %discnumber%==%track%

The Source expression relies on the CD letter to be always a capital.

---

<div class="post-metadata">

### Author: ![tripecac](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tripecac](https://community.mp3tag.de/u/tripecac)
#### Post date: [February 20, 2018, 8:02pm UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/3 "2018-02-20T20:02:03Z")

</div>

Hi, I just downloaded mp3tag and tried that action. Unfortunately, it didn't work; it simply changed the Discnumber to -64.

I'm guessing that this is because the "source" script expects the "A01" to already be in the Track field, which is not the case. Currently "A01" is only present in the filename: "A01 Back in the USSR.flac".

How can the script be modified so that it extracts the first "word" of the filename, where by "word" I mean a block of characters separated by whitespace?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 20, 2018, 8:06pm UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/4 "2018-02-20T20:06:49Z")

</div>

the I would use first the function  
Convert\>Filename-Tag  
Format string: %track% %title%

Like that you get structured data into the fields.

---

<div class="post-metadata">

### Author: ![tripecac](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tripecac](https://community.mp3tag.de/u/tripecac)
#### Post date: [February 20, 2018, 8:48pm UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/5 "2018-02-20T20:48:10Z")

</div>

Okay, thanks. If I populate the Track field first, then the Action works.

However, there are 2 changes I would like to make to the Action:

1. If a song is in a single-CD set, the track numbers are simply numeric (01, 02, 03, 04, etc.) and as a result the Action sets the Discnumber to a negative number (-16 for tracks 01-09 and -15 for tracks 10-19). So, it looks like it's subtracting 64 from the ASCII value of the first character of the Track string ("0" or "1"). Ideally, the Action would either leave the Discnumber field blank for single-disc sets, or at least set the Disc number to "1". Is this possible?

2. Can we omit the leading 0s from track numbers?

Ideally, "B02 Birthday.flac" would get Discnumber "2" and Track "1"  
...and "01 Come Together.flac" would get Discnumber "" or "1" and Track "1".

Is this possible?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 20, 2018, 8:59pm UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/6 "2018-02-20T20:59:17Z")

</div>

this is all different from your initial post.  
And different preconditions require different solution.  
You could filter for the ones that you want to treat:  
%track% HAS A OR %track% HAS B

And for the others you can use  
NOT %track% HAS A OR NOT %track% HAS B  
and then enter the discnumber via the extended tags dialogue (ALt-T)

---

<div class="post-metadata">

### Author: ![tripecac](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tripecac](https://community.mp3tag.de/u/tripecac)
#### Post date: [February 20, 2018, 10:30pm UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/7 "2018-02-20T22:30:33Z")

</div>

Is there a page which would teach me how to add preconditions to actions, so that I can try modifying the Action code?

Or even just a page which has good examples of how to parse filenames and tags in order to populate other tags, like your original Action did?

---

<div class="post-metadata">

### Author: ![tripecac](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/f4b2a3/32.png) [@tripecac](https://community.mp3tag.de/u/tripecac)
#### Post date: [February 20, 2018, 10:57pm UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/8 "2018-02-20T22:57:26Z")

</div>

Okay, I figured out what I needed by reading the documentation on this page:

> **[Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/)**
>
> Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

Here's my script, which parses the filename and adds both the Discnumber and Track:

$ifgreater($ord($left(%\_filename\_ext%,1)),64,$sub($ord($left(%\_filename\_ext%,1)),64),)==$add(0,$ifgreater($ord($left(%\_filename\_ext%,1)),64,$right($left(%\_filename\_ext%,3),2),$left(%\_filename\_ext%,2)))

This handles both single-disc and multi-disc sets.

For single-disc sets, it sets Discnumber to empty. Is it better form to leave it empty, or set Discnumber to 1 for single-disc sets?

---

<div class="post-metadata">

### Author: ![garym](https://community.mp3tag.de/user_avatar/community.mp3tag.de/garym/32/4822_2.png) [@garym](https://community.mp3tag.de/u/garym)
#### Post date: [February 21, 2018, 1:16am UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/9 "2018-02-21T01:16:16Z")

</div>

> [@tripecac](#):
>
> For single-disc sets, it sets Discnumber to empty. Is it better form to leave it empty, or set Discnumber to 1 for single-disc sets?

Personal preference. I don't add discnumber to single discs, but I know others that do.

---

<div class="post-metadata">

### Author: ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)
#### Post date: [February 22, 2018, 12:11am UTC](https://community.mp3tag.de/t/fixing-the-tags-for-multi-disc-albums-a01-a02-etc/40864/10 "2018-02-22T00:11:42Z")

</div>

> [@tripecac](#):
>
> [...]  
> For single-disc sets, it sets Discnumber to empty. Is it better form to leave it empty, or set Discnumber to 1 for single-disc sets?

I went through 3 or 4 major changes about tracks / discs over ~15 years  
  
  
Currently I store the number of disc at the end of the ALBUM name [so that it will be shown to me via Advanced Title Formatting o Winamp]

And the TRACK field I utilize for the exact number of disc, followed by a dot, followed by the number of the track  
  
  
And to answer your question: keep the 1 [by whatever means] to indicate disc 1, even if it is just a 1 disc album
