# Reset track number in filename for new disc

**URL:** https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693
**Category:** General Discussion
**Created:** [February 25, 2016, 10:03am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693 "2016-02-25T10:03:53Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Campus](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@Campus](https://community.mp3tag.de/u/Campus)
#### Post date: [February 25, 2016, 10:03am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693/1 "2016-02-25T10:03:53Z")

</div>

Hi,

I would like to separate the logical view of a multi-disc album from the physical view. Because of that the Track field should use all tracks from all discs: the first track from the first disc would be 01/28 and the last track of the second disc would be 28/28 in case both discs have 14 tracks. I managed to get this with the auto-numbering wizard without any problem.

Now I would like to keep the physical view for the file names, so the first track from the first disc is called [1] 01 - title - artist and the first track of the second disc should be [2] 01 - title - artist and the last track of the second album should be [2] 14 - title - artist.  
My current rename format is  
**['['$num(%discnumber%,2)']'] $num(%track%,2) - %title% - %artist%**

So how can I get the track number being reset for each additional disc?

Thanks.

Best,  
Campus

---

<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: [February 25, 2016, 11:47am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693/2 "2016-02-25T11:47:31Z")

</div>

In this case you have to apply a different sequence of steps, at first physical, then logical.

1. Renumber the tagfield TRACK for each disc separately.
2. Rename the filenames using DISCNUMBER and TRACK.
3. Renumber the tagfield TRACK for the entire group of discs.

DD.20160225.1347.CET

---

<div class="post-metadata">

### Author: ![Campus](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@Campus](https://community.mp3tag.de/u/Campus)
#### Post date: [February 26, 2016, 1:07am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693/3 "2016-02-26T01:07:20Z")

</div>

Thanks for the idea. This would probably work but would work only one time.  
So in case I would like to batch-rename my collection (for example to add the album name) I could not do this with this approach. Isn't their any other chance? Or could mp3tag maybe get another 'virtual' field like %track\_of\_disc%?

Thanks

---

<div class="post-metadata">

### Author: ![poster](https://community.mp3tag.de/user_avatar/community.mp3tag.de/poster/32/4881_2.png) [@poster](https://community.mp3tag.de/u/poster)
#### Post date: [February 26, 2016, 5:19am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693/4 "2016-02-26T05:19:04Z")

</div>

> [@Campus](#):
>
> Or could mp3tag maybe get another 'virtual' field like %track\_of\_disc%?

As you say you can add a self-defined tag-field for this purpose and using it for naming the files.

Just a warning:  
In case of self-defined tag-fields don't edit your tags with the windows-explorer. I noticed some side-effects doing this and tag corruption.

---

<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: [February 26, 2016, 8:01am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693/5 "2016-02-26T08:01:52Z")

</div>

> [@Campus](#):
>
> ... This ... would work only one time. ...

The proposed algorithm works for each new case. Once the algorithm has been done, there is no need to do it again on the same set of files.

> [@Campus](#):
>
> ... So in case I would like to batch-rename my collection (for example to add the album name) I could not do this with this approach. ...

As long as you do not change the propper filled fields DISCNUMBER, TRACK, \_FILENAME ...  
you can change other tag-fields as needed.  
To be safe for the future you may create one or more helper tagfields, e. g. create a tagfield TRACK\_ORIG to store the original physical tracknumber.

> [@Campus](#):
>
> ... Isn't their any other chance? Or could mp3tag maybe get another 'virtual' field like %track\_of\_disc%? ...

You may set up tagfields as you need it, but do not use reserved fieldnames.

DD.20160226.1001.CET

---

<div class="post-metadata">

### Author: ![Campus](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/919ad9/32.png) [@Campus](https://community.mp3tag.de/u/Campus)
#### Post date: [February 26, 2016, 10:46am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693/6 "2016-02-26T10:46:11Z")

</div>

First of all, thanks for your ideas I really appreciate that.

> [@DetlevD](#):
>
> The proposed algorithm works for each new case. Once the algorithm has been done, there is no need to do it again on the same set of files.  
> As long as you do not change the propper filled fields DISCNUMBER, TRACK, \_FILENAME ...  
> you can change other tag-fields as needed.  
> To be safe for the future you may create one or more helper tagfields, e. g. create a tagfield TRACK\_ORIG to store the original physical tracknumber.

Probably is DISCTRACK the way to go. Because as far as I can see it this is the only way to be able to rename files again with a slightly different scheme.

**[5 minutes later]** I tried this approach and its working very nice. The only remaining issue is now that I would like to have a ternary expression like **hasvalue(%disctrack%) ? %disctrack% : %track%** for the rename operation to avoid having to copy %track% to %disctrack% for single-disc albums as well.  
Any chance to accomplish that?

**[10 minutes later]** Ok, found it myself. In case someone is interested, my resulting rename format is ['['$num(%discnumber%,2)']' - ]$iflonger(%disctrack%,0,$num(%disctrack%,2),$num(%track%,2)) - %title% - %artist%

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: [February 26, 2016, 10:59am UTC](https://community.mp3tag.de/t/reset-track-number-in-filename-for-new-disc/17693/7 "2016-02-26T10:59:04Z")

</div>

> [@Campus](#):
>
> ... expression like **hasvalue(%disctrack%) ? %disctrack% : %track%**...

**$if(%DISCTRACK%,'then','else')****\_FILENAME \<== $if(%disctrack%,['['$num(%DISCNUMBER%,2)'] - ']$num(%DISCTRACK%,2)' - '%TITLE%' - '%ARTIST%,%\_filename%)****\_FILENAME \<== ['['$num(%DISCNUMBER%,2)'] - ']$num($if2(%DISCTRACK%,%TRACK%),2)' - '%TITLE%' - '%ARTIST%**

DD.20160226.1319.CET
