# Removing a certain number of characters from left or right of Filename using Replace with Regular Expression

**URL:** https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404
**Category:** Support
**Created:** [April 11, 2018, 2:23pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404 "2018-04-11T14:23:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Toonz](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/bbe5ce/32.png) [@Toonz](https://community.mp3tag.de/u/Toonz)
#### Post date: [April 11, 2018, 2:23pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/1 "2018-04-11T14:23:35Z")

</div>

I would like the ask the community on how to remove X(or N, whichever works) amount of ANY TYPE OF characters from a filename  
From the left side and then the expression that removes characters from the right side of the filename  
I prefer to use the action:

Replace with Regular Expression  
Field:  
\_FILENAME  
Regular Expression  
(This is where the community comes in)  
Replace Matches With  
(Blank)

I found the two ways on how to do this online, but a dying hard drive crash have made those saved expressions (?) lost and now cannot find them anywhere on the internet.

PLEASE...  
I have read enough lecturing and berating to last a lifetime on why people shouldn't even bother with this.  
I learned how to do this online YEARS ago and it is, for me, the most versatile.

Please no you should %artist% 1 part blah blah blah, please.

I can not thank you enough for your assistance on this ahead of time.

The HOURS (shudder I have been searching only to find posts of people being berated or asked why not do something else is frustrating.

To be clear  
If the filename is:  
ABCDEFGHIJKLMNOPQRSTUVWXYZ.mp3  
I want it to be removed 3 spaces from the left DEFGHIJKLMNOPQRSTUVWXYZ.mp3  
Then I'll also want to do 5 or 7 or how ever many

and then 4 or 5 or 7 or 10 spaces to the right? (I'll use 5 in this example)  
From ABCDEFGHIJKLMNOPQRSTUVWXYZ.mp3  
To ABCDEFGHIJKLMNOPQRSTUVWXY

If this sounds annoying, sorry. The amount of people not willing to answer this simple question is just frustrating.

The last one I tried was "$cutLeft(.,2)" but I know that wasnt what I used but wanted to try something before asknig on here.

Appreciate the help and thank you again.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [April 11, 2018, 2:31pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/2 "2018-04-11T14:31:05Z")

</div>

Hi and welcome 🙂

Not sure if I understand everything, but you can try the converter "Tag - Filename" with

`$cutLeft(%_filename%,3)`  
to remove 3 characters from the left and

`$cutRight(%_filename%,3)`  
to remove 3 characters from the right.

You can also combine the two with  
`$cutRight($cutLeft(%_filename%,3),3)`

---

<div class="post-metadata">

### Author: ![Toonz](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/bbe5ce/32.png) [@Toonz](https://community.mp3tag.de/u/Toonz)
#### Post date: [April 11, 2018, 2:34pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/3 "2018-04-11T14:34:07Z")

</div>

Added the $cutLeft(%\_filename%,3) expression in Regular Expression and did nothing....  
Is there a way to save it as an action?

Tag - Filename, found it, it did work!!! (YEAH) but if you dont mind, is there a way to create it as an action?

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [April 11, 2018, 2:37pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/4 "2018-04-11T14:37:40Z")

</div>

Not sure why you're insisting in using a regular expression for that? 😃 If there is a specific reason, please elaborate.

If you want to use my suggestion inside an action, just use a "Format value" action for `_FILENAME` using the format strings I've mentioned above.

---

<div class="post-metadata">

### Author: ![Toonz](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/t/bbe5ce/32.png) [@Toonz](https://community.mp3tag.de/u/Toonz)
#### Post date: [April 11, 2018, 2:40pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/5 "2018-04-11T14:40:55Z")

</div>

That did it! Never used it that way before, and having the action saved is a major help  
Thank you so much!  
Solved. 🙂

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [April 15, 2019, 8:45am UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/6 "2019-04-15T08:45:44Z")

</div>

7 posts were split to a new topic: [Remove certain string from end of filename](https://community.mp3tag.de/t/remove-certain-string-from-end-of-filename/45154)

---

<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: [March 8, 2024, 4:44pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/7 "2024-03-08T16:44:35Z")

</div>

A post was split to a new topic: [How to format Filename from "20171130 191142-6A4A3E01.mp4" to "2017-11-30.mp4"?](https://community.mp3tag.de/t/how-to-format-filename-from-20171130-191142-6a4a3e01-mp4-to-2017-11-30-mp4/64003)

---

<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: [March 8, 2024, 4:56pm UTC](https://community.mp3tag.de/t/removing-a-certain-number-of-characters-from-left-or-right-of-filename-using-replace-with-regular-expression/41404/8 "2024-03-08T16:56:19Z")

</div>


