# help w/ discnumber to filename

**URL:** https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446
**Category:** Support
**Created:** [February 9, 2007, 4:33pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446 "2007-02-09T16:33:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sinthome](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sinthome](https://community.mp3tag.de/u/sinthome)
#### Post date: [February 9, 2007, 4:33pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446/1 "2007-02-09T16:33:42Z")

</div>

ok im not so good with scripting, so be easy on me..

i want to rename tracks in multi-disc sets so that the filenames begin with the disc number. but i also want to trim the leading zero as well as the trailing total number of discs in the set (i have the discnumber field in the format 0n/0x).  
also, how would i implement this into my regular file renaming action so that IF there is a discnumber field, it will perform the above, and IF NOT then it will ignore the command?  
thanks!

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [February 9, 2007, 4:40pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446/2 "2007-02-09T16:40:13Z")

</div>

That should it be:  
[$num(%discnumber%,1)]

---

<div class="post-metadata">

### Author: ![sinthome](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sinthome](https://community.mp3tag.de/u/sinthome)
#### Post date: [February 9, 2007, 4:40pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446/3 "2007-02-09T16:40:37Z")

</div>

hmmm... actually- now i am wondering if people normally store the disc total in the same field as the discnumber.. or do they use two fields for each? is there any sort of standard on this?

[edit: oh wow fast reply! that worked great, even though i dunno how it knew to remove the total discs (??) but yay! thanks!!]

---

<div class="post-metadata">

### Author: ![sinthome](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sinthome](https://community.mp3tag.de/u/sinthome)
#### Post date: [February 11, 2007, 3:47pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446/4 "2007-02-11T15:47:00Z")

</div>

> [@dano](#):
>
> That should it be:  
> [$num(%discnumber%,1)]

this only works when the discnumber is present. otherwise it pads the track with a zero. is there a way to only add the discnumber when the field is present?

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [February 11, 2007, 3:57pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446/5 "2007-02-11T15:57:25Z")

</div>

That's what it does!  
The brackets are part of the expression, don't drop them.

---

<div class="post-metadata">

### Author: ![sinthome](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sinthome](https://community.mp3tag.de/u/sinthome)
#### Post date: [February 24, 2007, 5:28pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446/6 "2007-02-24T17:28:53Z")

</div>

ohhhh cool. thanks.

---

<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: [February 9, 2026, 12:20pm UTC](https://community.mp3tag.de/t/help-w-discnumber-to-filename/4446/7 "2026-02-09T12:20:08Z")

</div>


