# Can I update the TOTALTRACKS tag to find the max within a set where the album is the same

**URL:** https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159
**Category:** Mac
**Created:** [May 2, 2026, 9:58pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159 "2026-05-02T21:58:57Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 2, 2026, 9:58pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/1 "2026-05-02T21:58:57Z")

</div>

I have a TON of m4a files where for each track, the TOTALTRACKS tag is equal to the TRACK tag. That is, if an album has 10 songs, the TRACK tags are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and the corresponding TOTALTRACKS tags are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Is there a way where I could create an action that would update the TOTALTRACKS tags from: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) to (10, 10, 10, 10, 10, 10, 10, 10, 10, 10)

I can do this manually: select the tracks in an album, (make sure TOTALTRACKS is viewable on the left hand side) and change the value.

But, is there any way I could do this for many albums all at once? If you manually select all of the tracks in an album and then click on the TOTALTRACKS field on the left hand side, the drop down has only the values for that selection (as expected) - could there be a way to find the max TOTALTRACKS value based on an ALBUM name

I think in SQL you could do it like this:

`UPDATE Tracks t`  
`SET TOTALTRACKS = (`  
` SELECT MAX(t2.TRACK)`  
` FROM Tracks t2`  
` WHERE t2.ALBUM = t.ALBUM`  
`)`

No, I am not claiming that mp3tag can perform SQL operations, I just wanted to flesh this out and see if it would even be possible in SQL.

---

<div class="post-metadata">

### Author: ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)
#### Post date: [May 3, 2026, 1:32am UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/2 "2026-05-03T01:32:58Z")

</div>

You might have better success if you use the Auto- Numbering Wizard. It can assign track and disc numbers as well as the totals. If you already have the albums in their own folders this should be pretty straight forward.

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 4:02am UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/3 "2026-05-03T04:02:27Z")

</div>

Is that the Convert --\> Assign Track Numbers... ? I just tried it and it seems promising but for my test I took an album and manually set the TOTALTRACKS to 1 for each song. Then ran the "assign track numbers". It put a leading 0 on the TRACK, that's fine, but it kept the TOTALTRACKS at 1 for every track. Any thing I could add to get around this? Thanks

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 4:38am UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/4 "2026-05-03T04:38:29Z")

</div>

Okay, so further testing: If they are m4a files AND the TOTALTRACKS is set to some incorrect value, running this fixes everything up nicely. Excellent.

If they are FLAC files AND the TOTALTRACKS is set to some incorrect value then TOTALTRACKS does not get updated but TRACKS goes to the correct format of %track%/%totaltracks% - and then to fix the incorrect TOTALTRACKS follow it with "Import tag fields" that ohrenkino mentioned yesterday.

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 4:46am UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/5 "2026-05-03T04:46:34Z")

</div>

Taking this one step further...I had an Action (found in forums here) that would take the value after the / (In the TRACKS field) and update the TOTALTRACKS value:

`$if2(%totaltracks%,$if($neql(%TRACK%,$regexp(%track%,^\d{1','3}/(\d{1','3})$,$1)),$regexp(%track%,^\d{1','3}/(\d{1','3})$,$1),%totaltracks%))`

Doing the above, updates the TOTALTRACKS but keeps the TRACKS in its original format of x/y where as using the "Import tag field" changes both TRACK and TOTALTRACKS. People might want either or. I would like to take the action above and change it so that it ALWAYS updates the TOTALTRACKS regardless if TOTALTRACKS has a value or not. Currently if TOTALTRACKS has a value (even if it's incorrect) it won't update it. I'd like to adjust the action above to ALWAYS update the TOTALTRACKS if anyone could tell me how to edit that.

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 4:53am UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/6 "2026-05-03T04:53:51Z")

</div>

I took a guess and I think I got it:

`$if($neql(%TRACK%,$regexp(%track%,^\d{1','3}/(\d{1','3})$,$1)),$regexp(%track%,^\d{1','3}/(\d{1','3})$,$1),%totaltracks%)`

Just remove the opening `$if2(%totaltracks%,` and also remove the last `)`

---

<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: [May 3, 2026, 7:15am UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/7 "2026-05-03T07:15:56Z")

</div>

> [@raymondjiii](#):
>
> follow it with "Import tag fields" that ohrenkino mentioned yesterday.

You could use this "Import tag fields" also to update only TOTALTRACKS:  
Source: `%track%`  
Target: `%dummy%/%totaltracks%`

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 1:12pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/8 "2026-05-03T13:12:50Z")

</div>

One problem I found using the "Assign Track Numbers..." is that even if the albums are in different directories it increments the disc number as it traverses the directories. So I think the easiest approach is to just uncheck the "Assign disc numbers" as this solves my initial concern. I wonder what this process uses to assign the track numbers? Is it just the leading values of the filename?

---

<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: [May 3, 2026, 1:16pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/9 "2026-05-03T13:16:08Z")

</div>

AFAIK you can set various criteria to determine the start of the next set.  
In many cases this could be the next folder but if an ablum stretches over several folders, it would be the contents of ALBUM.

And no: it is not

> [@raymondjiii](#):
>
> just the leading values of the filename

If you have problems with the track numbering converter, please show us a screenshot of the current settings you are using for the assistant.

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 2:30pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/10 "2026-05-03T14:30:30Z")

</div>

How can I see the "settings" used for this?

---

<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: [May 3, 2026, 2:33pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/11 "2026-05-03T14:33:38Z")

</div>

⌘ K Assign Track Numbers...  
should open a window/dialogue in which you can see the settings.

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 7:23pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/12 "2026-05-03T19:23:39Z")

</div>

But that does not indicate how track numbers are determined, only from where the numbering starts and if you want to restart at each directory. I'm asking, if a set of tracks had no "TRACK" value then how does it determine the correct ordering for an album (or a directory) ?

---

<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: [May 3, 2026, 7:26pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/13 "2026-05-03T19:26:47Z")

</div>

Not at all - you have to put the file into the correct order and then start the numbering assistant.

---

<div class="post-metadata">

### Author: ![raymondjiii](https://community.mp3tag.de/user_avatar/community.mp3tag.de/raymondjiii/32/17213_2.png) [@raymondjiii](https://community.mp3tag.de/u/raymondjiii)
#### Post date: [May 3, 2026, 7:57pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/14 "2026-05-03T19:57:54Z")

</div>

Right - and the easiest way to to do this is to prefix the "to be track number" at the front of each file so they can easily sort in mp3tag.

---

<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: [May 3, 2026, 8:00pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/15 "2026-05-03T20:00:46Z")

</div>

Or sort them by the creation date ... assuming that they got created in the correct order by the ripping program.  
Or other criteria that ease the sorting.

---

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [May 3, 2026, 9:09pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/16 "2026-05-03T21:09:58Z")

</div>

> [@raymondjiii](#):
>
> Doing the above, updates the TOTALTRACKS but keeps the TRACKS in its original format

That was the intended behavior:

> [@TOTALDISCS / DISCNUMBER differences Foobar2000 and MP3tag](https://community.mp3tag.de/t/totaldiscs-discnumber-differences-foobar2000-and-mp3tag/64964/10):
>
> This leaves TOTALDISCS alone if it's already populated

> [@raymondjiii](#):
>
> I had an Action (found in forums here)

It's usually a good idea to [link](https://community.mp3tag.de/t/totaldiscs-discnumber-differences-foobar2000-and-mp3tag/64964/10) to the source of things that you copy and try to adjust for your use case.

---

<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: [May 10, 2026, 9:10pm UTC](https://community.mp3tag.de/t/can-i-update-the-totaltracks-tag-to-find-the-max-within-a-set-where-the-album-is-the-same/71159/17 "2026-05-10T21:10:58Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
