# Insert Track Number Into Title

**URL:** https://community.mp3tag.de/t/insert-track-number-into-title/1783
**Category:** General Discussion
**Created:** [March 15, 2005, 7:56am UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783 "2005-03-15T07:56:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Alexi](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@Alexi](https://community.mp3tag.de/u/Alexi)
#### Post date: [March 15, 2005, 7:56am UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/1 "2005-03-15T07:56:16Z")

</div>

This should be simple but does not work. I would like to insert into the TITLE tag the track number. Currently there is a dummy string "#" in the title tag and I wish to replace it with the actual track number. I'm using the Replace with Regular Expression, where "Field" = "TITLE", "Regular expression" = "#", and "Replace matches with" = "$num(%track%,3)". This returns a value of '000'. I'm expecting the actual value of the track number padded with two zeros. How can I get this to work?

Thanks. ![<_<](https://community.mp3tag.de/uploads/default/original/1X/5996dbb474c88b8f9fc49f09dc3858d081055a2d.gif "<\_<")

---

<div class="post-metadata">

### Author: ![Sebastian\_Mares](https://community.mp3tag.de/user_avatar/community.mp3tag.de/sebastian_mares/32/9285_2.png) [@Sebastian\_Mares](https://community.mp3tag.de/u/Sebastian_Mares)
#### Post date: [March 15, 2005, 9:39am UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/2 "2005-03-15T09:39:24Z")

</div>

> [@](#):
>
> This should be simple but does not work. I would like to insert into the TITLE tag the track number. Currently there is a dummy string "#" in the title tag and I wish to replace it with the actual track number. I'm using the Replace with Regular Expression, where "Field" = "TITLE", "Regular expression" = "#", and "Replace matches with" = "$num(%track%,3)". This returns a value of '000'. I'm expecting the actual value of the track number padded with two zeros. How can I get this to work?
> 
> Thanks. ![<_<](https://community.mp3tag.de/uploads/default/original/1X/5996dbb474c88b8f9fc49f09dc3858d081055a2d.gif "<\_<")
> 
> \<{POST\_SNAPBACK}\>

Well, it doesn't work the way you want, AFAIK. If you want to add a track number at the beginning of the title field, simply replace "#" by nothing and add another action which formats values. Use TITLE as field and "$num(%track%,3) %title%" as format string.

---

<div class="post-metadata">

### Author: ![Alexi](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@Alexi](https://community.mp3tag.de/u/Alexi)
#### Post date: [March 15, 2005, 1:52pm UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/3 "2005-03-15T13:52:59Z")

</div>

> [@](#):
>
> Well, it doesn't work the way you want, AFAIK. If you want to add a track number at the beginning of the title field, simply replace "#" by nothing and add another action which formats values. Use TITLE as field and "$num(%track%,3) %title%" as format string.
> 
> \<{POST\_SNAPBACK}\>

Are you saying I cannot _insert_ the track number in the middle of the TITLE string using Mp3tag? Does Mp3tag have an enumerate function which would apply to a selection of files/tags? Something like $enum(x,y), where x=starting value, and y=increment. Also, the ability to create variables which are based on information in tags would be nice.

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: [March 15, 2005, 3:12pm UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/4 "2005-03-15T15:12:48Z")

</div>

I don't know if I understand this right, but you can try FORMAT VALUE on TITLE with:  
$left(%title%,$sub($strchr(%title%,#),1))$num(%track%,3)$right(%title%,$sub($strchr(%title%,#),1))

---

<div class="post-metadata">

### Author: ![Alexi](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@Alexi](https://community.mp3tag.de/u/Alexi)
#### Post date: [March 15, 2005, 3:35pm UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/5 "2005-03-15T15:35:46Z")

</div>

> [@](#):
>
> I don't know if I understand this right, but you can try FORMAT VALUE on TITLE with:  
> $left(%title%,$sub($strchr(%title%,#),1))$num(%track%,3)$right(%title%,$sub($strchr(%title%,#),1))
> 
> \<{POST\_SNAPBACK}\>

Thanks dano!

This is very close. If I start with this title: "Sonata in D Major, K. # -- Allegro" and apply your expression, I get "Sonata in D Major, K. 161Major, K. # -- Allegro". The result should be "Sonata in D Major, K. 161 -- Allegro".

---

<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: [March 15, 2005, 3:46pm UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/6 "2005-03-15T15:46:19Z")

</div>

Ok, I didn't look what $right really does 😉  
Sp replace  
$right(%title%,$sub($strchr(%title%,#),1))  
with  
$right(%title%,$sub($len(%title%),$strchr(%title%,#)))

---

<div class="post-metadata">

### Author: ![Alexi](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@Alexi](https://community.mp3tag.de/u/Alexi)
#### Post date: [March 15, 2005, 3:54pm UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/7 "2005-03-15T15:54:40Z")

</div>

> [@](#):
>
> Ok, I didn't look what $right really does 😉  
> Sp replace  
> $right(%title%,$sub($strchr(%title%,#),1))  
> with  
> $right(%title%,$sub($len(%title%),$strchr(%title%,#)))
> 
> \<{POST\_SNAPBACK}\>

dano,

This worked beautifully. Brilliant, you saved me much work. Where can I learn more about scripting for Mp3tag?

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: [March 15, 2005, 4:19pm UTC](https://community.mp3tag.de/t/insert-track-number-into-title/1783/8 "2005-03-15T16:19:52Z")

</div>

In Mp3tag, press F1 and you see the Help.  
There's a link to the scripting reference.
