# Adding Leading Zeros to File, Album & Directory Names

**URL:** <https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066>\
**Category:** Support\
**Created:** [January 1, 2019, 9:40am UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066 "2019-01-01T09:40:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 1, 2019, 9:40am UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/1 "2019-01-01T09:40:19Z")

</div>

Hello everyone,

If I wanted to locate and rename file & album names which include 1-9 in the title for song numbers and albums with many discs, how would I first filter to show only those and secondly, add leading zeros without messing up the remainder of the file/album/directory names?

I look forward to receiving your reply, thank you in advance.

---

<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:** [January 1, 2019, 3:24pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/2 "2019-01-01T15:24:57Z")

</div>

You can filter for fields with a single number with  
`%fieldname% MATCHES \d`  
To rename files and folders it is advisable to get the data in the tag fields correct and then rename the files. Please note that a number of characters are invalid for filenames or folders.  
You can rename files and folders with actions of the type "Format value" or the functions in the Convert menu.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 1, 2019, 7:16pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/3 "2019-01-01T19:16:02Z")

</div>

Thank you for your reply. Let's use an example, there are two that I can think of. The first is Now That's What I Call Music.

I changed the track names so that they include the track number with no leading zero, then the song name, followed by the artist name in brackets. I then change the artist name in the artist and artists field from the true artist to Now That's What I Call Music because when I haven't done this in the past it has messed up my folder structure in Windows Media Player.

In this example, I would like to add a leading zero to the file name without adding a leading zero to the track number. I would also like to make sure that Vol. 02 appears this way, if it doesn't have a leading zero then one should be added. At the same time, I would need to avoid adding a leading zero to the Disc number. The same would apply to the directory.

 ![image](https://community.mp3tag.de/uploads/default/original/2X/0/0ec7972c683a792f8348599aa8d23ff66394bc40.png)

Once this has been figured out I will mention the second example.

Thanks for your help.

---

<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:** [January 1, 2019, 7:21pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/4 "2019-01-01T19:21:30Z")

</div>

You can create a new filename (without touching the data in the tag fields) with:  
Convert\>Tag-Filename  
Format string: `$num(%track%,2)_%title%`  
(I would recommend a character other than the space character to separate the fields, e.g. the underscore. If you do not like it, the use whatever you want)

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 2, 2019, 6:49pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/5 "2019-01-02T18:49:51Z")

</div>

Thanks for your reply, going back a step to get the filter right, how do I filter for 1-9?

Take the filename for example, how do I make it match files with 1-9?  
%\_FILENAME% MATCHES \d

---

<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:** [January 2, 2019, 6:58pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/6 "2019-01-02T18:58:27Z")

</div>

Have you tried it?  
I mean: typing your post takes longer than testing it in MP3tag.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 2, 2019, 7:00pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/7 "2019-01-02T19:00:24Z")

</div>

Yes I did try it first, it came up with no results when there were loads of files with 1-9 in the filename.

Trying %\_FILENAME% MATCHES 0\d instead brought up more likely results but also numbers from 10+ and not all tracks numbered 1-9 in the filename.

 ![image](https://community.mp3tag.de/uploads/default/original/2X/7/76da61966fc9f5d7a87a28f5b2d212feef559b6c.png)

Considering that there are 182 discs, there should be 1,638 tracks found with the filter.

---

<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:** [January 2, 2019, 7:08pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/8 "2019-01-02T19:08:40Z")

</div>

If you want to filter for a number at the beginning, use  
`..... MATCHES "^\d"`  
If you want to filter for a single number at the beginning which is followed by a space character, use  
`..... MATCHES "^\d "`  
the dots stand for the fieldname.  
All this and more is revealed in the help

> **[Filter and Search – Mp3tag Documentation](https://docs.mp3tag.de/filter/)**
>
> Documentation on Filter and Search and keywords to form complex filter expressions. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 2, 2019, 7:27pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/9 "2019-01-02T19:27:12Z")

</div>

Thank you, %\_FILENAME% MATCHES "^\d " works well. I will go back to testing.

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 2, 2019, 9:13pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/10 "2019-01-02T21:13:54Z")

</div>

That works well.

Filter  
%\_FILENAME% MATCHES "^\d "

Action  
Format value  
\_FILENAME

Format string  
$num(%track%,2) %title%

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 3, 2019, 7:38pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/11 "2019-01-03T19:38:12Z")

</div>

Is it possible to filter by a number of words, which are listed and case sensitive? For example, I want to check that words such as 'the', to' and 'at' are lower case so I would like to find any which are upper case 'The', 'To' and 'At' so that I can correct it.

---

<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:** [January 3, 2019, 7:43pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/12 "2019-01-03T19:43:52Z")

</div>

`%title% MATCHES "(?-i) The"`  
filters for " The"

---

<div class="post-metadata">

**Author:** ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)\
**Post date:** [January 3, 2019, 7:48pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/13 "2019-01-03T19:48:52Z")

</div>

Brilliant, thank you. Is it possible to combine several so it searches for one or more like the examples I listed within one filter query?

---

<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:** [January 3, 2019, 7:50pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/14 "2019-01-03T19:50:21Z")

</div>

see the help on the filter options:

> **[Filter and Search – Mp3tag Documentation](https://docs.mp3tag.de/filter/)**
>
> Documentation on Filter and Search and keywords to form complex filter expressions. Mp3tag is the universal Tag Editor.

(which I linked before)  
Have a look at the descriptions for AND, OR and NOT

---

<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:27pm UTC](https://community.mp3tag.de/t/adding-leading-zeros-to-file-album-directory-names/44066/15 "2026-02-09T12:27:50Z")

</div>


