# How can I remove only the leading zero from filename and only if number has three digits?

**URL:** <https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109>\
**Category:** Support\
**Created:** [January 29, 2022, 10:01am UTC](https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109 "2022-01-29T10:01:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simos\_Sigma](https://community.mp3tag.de/user_avatar/community.mp3tag.de/simos_sigma/32/9966_2.png) [@Simos\_Sigma](https://community.mp3tag.de/u/Simos_Sigma)\
**Post date:** [January 29, 2022, 10:01am UTC](https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109/1 "2022-01-29T10:01:14Z")

</div>

Hello community!!! 🙂

I have a bunch of tracks and their file names contain three digits at start. Something like this:  
`001 - Filename.mp3`  
`060 - Filename.mp3`  
`086 - Filename.mp3`  
`...`

As the title "says"... Is there any way to remove only the leading zero from filename and only if number has three digits?

Thank you for your time!!! 🙂

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [January 29, 2022, 11:04am UTC](https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109/2 "2022-01-29T11:04:34Z")

</div>

You could try it with this regular expression:  
`$regexp(%_FILENAME%,'^0+?(\d{2})',$1)`

using Convert Tag -\> Tag (or an Action):  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/0/0c42d3417beaf488e4ed5e0e768e4d24db739938.png)

Short explanation:  
Search for a zero at the start of the filename. it must be followed by 2 more numbers.  
If found, keep only the two numbers (= remove the first zero).

Test and examples: [regex101: build, test, and debug regex](https://regex101.com/r/IAB31b/1)

---

<div class="post-metadata">

**Author:** ![Simos\_Sigma](https://community.mp3tag.de/user_avatar/community.mp3tag.de/simos_sigma/32/9966_2.png) [@Simos\_Sigma](https://community.mp3tag.de/u/Simos_Sigma)\
**Post date:** [January 29, 2022, 11:28am UTC](https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109/3 "2022-01-29T11:28:42Z")

</div>

Thank you so much!!! It's done!!! 😀  
I think I should find some time to study `regexp` syntax... It's making miracles!!! 😆

One more question please. If I would like to do this with an action?

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [January 29, 2022, 11:33am UTC](https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109/4 "2022-01-29T11:33:07Z")

</div>

> [@Simos\_Sigma](#):
>
> If I would like to do this with an action?

What have you already tried?

[Create a new action](https://docs.mp3tag.de/actions), select action type "Replace with regular expression".  
Fill the dialog box like this:  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/8/869d4b4d72b7638a20262dfbfb0655eee10671c8.png)

---

<div class="post-metadata">

**Author:** ![Simos\_Sigma](https://community.mp3tag.de/user_avatar/community.mp3tag.de/simos_sigma/32/9966_2.png) [@Simos\_Sigma](https://community.mp3tag.de/u/Simos_Sigma)\
**Post date:** [January 29, 2022, 11:44am UTC](https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109/5 "2022-01-29T11:44:57Z")

</div>

Worked too!!! 🙂  
And I also get an idea of the part of `regexp`!!! What is what...

Thank you very much for your precious time **LyricsLover**!!!  
You really helped me here!!! 🙂

---

<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 28, 2022, 11:45am UTC](https://community.mp3tag.de/t/how-can-i-remove-only-the-leading-zero-from-filename-and-only-if-number-has-three-digits/56109/6 "2022-02-28T11:45:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
