# How to replace leading zeros in track numbers with 2 blank characters?

**URL:** https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387
**Category:** Support
**Created:** [June 3, 2026, 4:45am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387 "2026-06-03T04:45:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 3, 2026, 4:45am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/1 "2026-06-03T04:45:37Z")

</div>

I have this setup for my "copy as text"

♫ $validate($num(%track%,1), ) ▪ %artist% ▪ %title% ▪ $regexp(%\_length%,^0(\d:),$1)

How do I get it to add 2 "blank characters" before single digit numbers. I tried using Alt+0160 twice for 2 blank characters but it doesn't seem to add them when actually pasting the tags to the place I

---

<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: [June 3, 2026, 5:33am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/2 "2026-06-03T05:33:34Z")

</div>

"Where do you want these? In the tracknumber?  
`$num(%track%,3)`

---

<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: [June 3, 2026, 5:59am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/3 "2026-06-03T05:59:55Z")

</div>

> [@Stealth](#):
>
> How do I get it to add 2 "blank characters" before single digit numbers

AFAIK filenames with leading space characters are invalid. That is why they get cut away with $validate(). But as leading `0` are valid characters anyway, I wonder what $validate() should do in this case.

---

<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: [June 3, 2026, 7:42am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/4 "2026-06-03T07:42:02Z")

</div>

I hadn't realized that leading blanks - rather than zeros - were actually intended to be inserted; hence my previous response.

To prevent standard spaces (0x20) from appearing at the beginning or end of a filename in the first place, there is no need for `$validate()`, as the operating system itself prevents this.

> **[Whitespace characters in file and folder names - Windows Client](https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/file-folder-name-whitespace-characters)**
>
> Describes support for whitespace characters in file and folder names.

This Microsoft article also points to other whitespace characters that might potentially be used to achieve the goal; however, I would strongly advise against pursuing such unconventional approaches.

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 3, 2026, 12:58pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/5 "2026-06-03T12:58:40Z")

</div>

I accidently hit enter or something while typing my original post and I had no way of editing it because it went straight to pending approval sorry!

This is being used for the copy tags to text feature so that I can copy and paste an albums information to another forum. I am trying to add 2 leading spaces (using blank characters from the character map) before single digit numbers because that is what is needed to make the information align how I want when posting to the forum. I was also trying to use the Alt+ whatever for the blank character instead of just using spaces as when I manually type the information into the other forum it deletes the leading spaces but using the "blank character" the forum doesn't delete those when posting. I am not at home now to show you how it looks, but I am not using any of this to change tags or file names its just for posting the tag information. It may not be possible but hopefully you understand what I am trying to do now.

---

<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: [June 3, 2026, 1:06pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/6 "2026-06-03T13:06:15Z")

</div>

In that case do not use $validate() as that removes the leading spaces even if they were there.  
If you have special characters to add then you could use $char() or even $repeat($char(),x) to insert them as leading characters.

See more scripting functions in the documentation:

> **[String Functions - Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/#string-functions)**
>
> Mp3tag offers various built-in scripting functions, which can be used at various places in the program. | Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 3, 2026, 1:32pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/7 "2026-06-03T13:32:22Z")

</div>

When I get home hopefully I can figure out the exact string to remove the 0 from single digit numbers and replace with a character but would char string then be $repeat($char(0160),2) because Alt+0160 is what I remember it saying on the Windows character map.

$num(%track%,1,$repeat($char(0160),2) is it something like 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: [June 3, 2026, 1:47pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/8 "2026-06-03T13:47:32Z")

</div>

> [@Stealth](#):
>
> $num(%track%,1,$repeat($char(0160),2) is it something like this?

If the spaces should be in front, it should be:  
`$repeat($char(0160),2)$num(%track%,1)`  
($char() expects a decimal number - 352?)

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 3, 2026, 2:00pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/9 "2026-06-03T14:00:04Z")

</div>

Yes the spaces should be in front of the single digit numbers.

Google tells me the decimal code for "No-Break Space" is 160 which is just the blank char I was using 2 of to get it to align how I wanted, does this sound right?

---

<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: [June 3, 2026, 2:48pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/10 "2026-06-03T14:48:19Z")

</div>

> [@Stealth](#):
>
> decimal code for "No-Break Space" is 160

`0160` looked hexadecimal to me - I just wanted to make sure that you use the right codeformat.  
For everything else, I would say: try it.

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 3, 2026, 11:02pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/11 "2026-06-03T23:02:31Z")

</div>

It's adding the spaces in front of the double digit numbers like 10, 11, 12 also. Not a big deal as I don't think the forum for some reason is accepting the chars as anything other than spaces, even though if I manually put the chars in it uses them. Any

Edit: actually it would work if I could get it to not put the spaces in front of 2 digit numbers! Any ideas?

---

<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: [June 4, 2026, 5:55am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/12 "2026-06-04T05:55:58Z")

</div>

Try:  
`$repeat($char(160),$sub(4,$len($num(%track%,1)))´

The `4` has to be adapted to define how long the string should be of "number plus space"

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 4, 2026, 11:24pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/13 "2026-06-04T23:24:50Z")

</div>

No matter what I change the number 4 to it does not show the track number at all using this string haha.

I can add %track% after the string to show the track numbers but they still all have the same amount of break spaces.

---

<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: [June 5, 2026, 5:46am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/14 "2026-06-05T05:46:15Z")

</div>

> [@Stealth](#):
>
> I can add %track% after the string to show the track numbers but they still all have the same amount of break spaces

`♫ $repeat($char(160),$sub(4,$len($num(%track%),1)))$num(%track%,1) - %artist% - %title%`  
works here.

---

<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: [June 5, 2026, 5:54am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/15 "2026-06-05T05:54:57Z")

</div>

> [@Stealth](#):
>
> No matter what I change the number 4 to it does not show the track number at all using this string

That is why screenshots or real code examples would help much more than just claims that something does not work.

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 5, 2026, 11:53am UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/16 "2026-06-05T11:53:00Z")

</div>

Using this code: ♫ $repeat($char(160),$sub(4,$len($num(%track%),1)))$num(%track%,1) ▪ %artist% ▪ %title% ▪ $regexp(%\_length%,^0(\d:),$1)

Makes the top version of this screenshot.

Manually deleting (2 back spaces) the 2 break spaces from Tracks 10-14 produces the bottom version of the screenshot, which is what I am trying to achieve.

 ![image](https://community.mp3tag.de/uploads/default/original/3X/1/b/1b56a5ff0ab4f75658d9bd2adc11614df3d4f1cd.png)

---

<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: [June 5, 2026, 12:18pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/17 "2026-06-05T12:18:31Z")

</div>

> [@Stealth](#):
>
> `$num(%track%),1)`

should be  
`$num(%track%,1))`

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 5, 2026, 1:15pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/18 "2026-06-05T13:15:09Z")

</div>

Like this: ♫ $repeat($char(160),$sub(4,$len($num(%track%,1)))$num(%track%,1)) ▪ %artist% ▪ %title% ▪ $regexp(%\_length%,^0(\d:),$1)

That just puts a giant space with no track numbers.

---

<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: [June 5, 2026, 1:20pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/19 "2026-06-05T13:20:51Z")

</div>

With  
`♫ $repeat(#,$sub(4,$len($num(%track%,1))))$num(%track%,1) * %artist% * %title% * $regexp(%_length%,^0(\d:),$1)`  
I get

```auto
♫ ###6 * Aural Float * Pick up The Virus MacNeal (wThe Hugo Winterhalter) * 11:18
♫ ##96 * Taklamakan * Taklamakan [Pt.1] * 14:52
♫ ##97 * 4jäx 1/1/00 * Story of 6 - 6, Life * 15:46
♫ ##98 * Bix * Piano for the Moment * 12:07
♫ ##99 * Fortunato & Montresor * Imagine [Imagination 1] * 6:41
♫ #100 * Cold * Strobe Light Network [Flow machine remix] * 8:52

```

I used the `#` to illustrate the number of repeats

---

<div class="post-metadata">

### Author: ![Stealth](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@Stealth](https://community.mp3tag.de/u/Stealth)
#### Post date: [June 5, 2026, 2:47pm UTC](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387/20 "2026-06-05T14:47:42Z")

</div>

> [@ohrenkino](#):
>
> ♫ $repeat(#,$sub(4,$len($num(%track%,1))))$num(%track%,1) \* %artist% \* %title% \* $regexp(%\_length%,^0(\d:),$1)

that appears to be working for me also with the # symbol showing, now how can I make it use my special breakspace instead haha.

Edit:

♫ $repeat($char(160),$sub(4,$len($num(%track%,1))))$num(%track%,1) ▪ %artist% ▪ %title% ▪ $regexp(%\_length%,^0(\d:),$1)

may work.

Edit 2: Maybe not ☹

[Next page](https://community.mp3tag.de/t/how-to-replace-leading-zeros-in-track-numbers-with-2-blank-characters/71387.md?page=2)
