Increment ALBUM tag name every folder

Hello there

I have a folder album, in it have have all sub-folders like :

CD1
CD2
CD3

and so on. They all have the same ALBUM tag

I want to rename the ALBUM tags of all of those with an increment number, so that they will be :

(in CD1 folder) : ALBUM CD01
(in CD2 Folder) : ALBUM CD02
etc…

For now what I have found is :
%album% CD$num(%_counter%,2)

It sort of work, my problem is it increment every (selected) track, and not every folder, so each track have his own album name doing this

What is the function to use to make it understand that it should stick to the counter for every folder, and then increment it only at the next folder?

I have also think about using the disc number tag (DISC I think), but I prefer to use the folder change (and if I know how to do it this way, I will probably be able to guess how to do it witch disc change to)

Regards

Use the auto numbering wizard Ctrl-K and set only the disc number

That’s not what I’m trying to do at all

AFAI understand it:
You want to set an increasing number for each album as long as the album stays the same but change that number when the folder changes.
This is exactly what you can set with the wizard.
The wizard is also the only function that looks at data from the previous file.
You set the discnumber first and then rename the folder / the album with the data from the tag fields.

I recommend against doing this. It might seem simpler to edit the ALBUM tag but mixing different tags in a single field WILL become messy.

Many years ago I went down that route by adding [CD 1] etc. to the ALBUM tags of my files if the DISCTOTAL is >1.

This approach works if you then use the DISCNUMBER tag to rename the ALBUM tag (it only works if you do not have “save total count of discs” checked in the Auto-numbering wizard).

Instead you can use %album% CD$num(%discnumber%,2)

I later on wanted to account for different cases of DISCNUMBER tags and safeguard this step so I could run it on all files:

01 vs. 1/1 vs. 01/01, splitting the total count off into DISCTOTAL, ignoring the cases where there is only a single disc, only appending the number when the DISCTOTAL is >=2, appending [CD 1] when there’s fewer than 10 discs or [CD 01] when there are more and so on.

While it works for the majority of cases I’d never recommend doing it as it’s an absolute mess.
It’s been years since I’ve written the action group and it works for me, but see the madness for yourself…

You’re way better off by simply populating the DISCNUMBER tag and then using this for creating folder names and so on. Pretty much any modern audio player uses it properly so there is usually no need to taint the ALBUM tag.

Not totally correct, I think. If you use, as the OP suggested the $num() function then the part starting with the slash is ignored as $num() interprets only the numeric part. So a $num('2/3',1) will return just 2.
But you are right: DISCNUMBER would have to be filled first.

I have CD1 folder, CD2 folder, CD3 folder etc.. They all have the same ALBUM tag because they are all part of the same album.
To distinguish them,I want to add CD1 to the tag name (after the album name in the tag), CD2 to the tag name (after the album name in the tag) etc…

What I have suggest is almost doing it, (try by yourself), the thing is, it increment the number every track, and not every folder / album / disc, so I need the formula to make mp3tag to understand that he should only increment by album / folder / disc and not by track

And this is, again, not possible with an action but only with the auto-numbering wizard.
If you want to keep the DISCNUMBER as it is, save it to a user-defined field before you apply the wizard.
Then use the data from the tag field DISCNUMBER to modify ALBUM.
In the end, set DISCNUMBER to the old value.

Ok that was the solution :+1:

So because there is almost no album with more than 10 CD / part, I have limited it to one digit only, this way :

%album% CD$num(%discnumber%,1)

So, I’m doing this action first, to add “ CD1”, “ CD2”, “ CD3” etc to the album name (add it, and not replace it). And after that, I use another action :

[%albumartist% - ][$left(%YEAR%,4) - ][%album%]

So, to understand my final goal there (and for those coming here in a few years / month via Google or else), I start from :

Crazy Frog Greatest Hits/CD1/tracks.mp3
Crazy Frog Greatest Hits/CD2/tracks.mp3
Crazy Frog Greatest Hits/CD3/tracks.mp3
Crazy Frog Greatest Hits/CD4/tracks.mp3

To obtain :

Crazy Frog - 2025 - Greatest Hits CD1/tracks.mp3
Crazy Frog - 2025 - Greatest Hits CD2/tracks.mp3
Crazy Frog - 2025 - Greatest Hits CD3/tracks.mp3
Crazy Frog - 2025 - Greatest Hits CD4/tracks.mp3

My goal in the end is to not have an album folder with all CD sub-folders in it, but to have separate album folders with the “CD1”, CD2” etc in the folder, and tag, name (in booth, mostly because I rely on the tag name to create the folder name)

This way, when I see my music folder in the file explorer, I can see if it is a multiple CD / folders album or not, without the need to click into every folder to check in

But, because I have to do this operation to hundred (if not thousand) of folders, well, I was in need of an action to make it the quickest possible.

Thank all of you for the help

Yes, right, total disc or not it’s the same. And fortunately all my Multi CD / folder albums have the disc number tag, so I will rely on that, instead of the folder change, to increment the number in the ALBUM tag (and afaik there is no way to indicate to mp3tag to do something at folder change, he dosen’t get it)

$num(xxx,1) does not limit the number to 1 digit but does not add padding for numbers that have less than 1 digit. $num(xxx,1) transforms a string into a numeric value.

There is: the auto-numbering wizard. But you have to save the number in either TRACK or DISCNUMBER.
if you have set DISCNUMBER (or a different suitable number) already, then the way to modify ALBUM is as described, yet the attempt with %_counter% does not lead to the desired result.

As I suspected, your goal is to rename folders.
You could achieve the same folder names without modifying the ALBUM tag like this:

[$validate(%albumartist%,-) - ][$left(%YEAR%,4) - ][$validate(%album%,-)][$if($or($grtr($num(%discnumber%,1),1),$grtr(%disctotal%,1)), CD$num(%discnumber%,2),)]

I’ve added validation to ALBUMARTIST and ALBUM to replace restricted characters with -. I’ve also added logic to only append the CDXX part when either the DISCNUMBER or DISCTOTAL is >1. You’d have to adjust this if you don’t use the DISCTOTAL tag.
This way this action only adds the CDXX suffix when the tags indicate a multi-disc album.

Doing it like this has the advantage that you don’t mix different fields into one, which makes working with the information within the mixed field way harder (and usually only possible if you are well versed in regex).
While “simply” editing the ALBUM tag might seem the better solution at first, I suspect that you’ll eventually come to regret having done it just like I do. Picking apart mixed fields after the fact is annoying, even in the unlikely case that you -like me- do like regex.