# RegEx Remove from FileName

**URL:** https://community.mp3tag.de/t/regex-remove-from-filename/5265
**Category:** Support
**Created:** [August 6, 2007, 1:56am UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265 "2007-08-06T01:56:52Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![studley](https://community.mp3tag.de/user_avatar/community.mp3tag.de/studley/32/144_2.png) [@studley](https://community.mp3tag.de/u/studley)
#### Post date: [August 6, 2007, 1:56am UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/1 "2007-08-06T01:56:52Z")

</div>

I wish to remove xyz or 256 and everything AFTER it in a filename. Can someone help me?

Thanks,  
David

---

<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: [August 6, 2007, 2:03pm UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/2 "2007-08-06T14:03:52Z")

</div>

2 possible ways:

a ) Rename your file with the content of your existing ID3-Tags like %ARTIST% - %ALBUM% - %TRACK% -%TITLE% and the Converter ALT-1

b ) Write an Action for the field \_FILENAME to remove "xyz or 256 and everything AFTER it in a filename"

---

<div class="post-metadata">

### Author: ![studley](https://community.mp3tag.de/user_avatar/community.mp3tag.de/studley/32/144_2.png) [@studley](https://community.mp3tag.de/u/studley)
#### Post date: [August 6, 2007, 6:50pm UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/3 "2007-08-06T18:50:50Z")

</div>

Sorry I wasn't more specific. I am looking for someone to help me with the Regex for the action you described in option b.

Thanks in advance,  
David

---

<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: [August 7, 2007, 2:57pm UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/4 "2007-08-07T14:57:34Z")

</div>

If you really want remove "xyz or 256 and everything AFTER it in a filename", you could use this:

Actiontype "Replace with Regular Expression"  
_(I'm not sure about the text, because I don't use the english version...)_  
**Field:** \_FILENAME  
**Regular Expression:** (xyz._)|(256._)  
**Replace matches with:**.mp3  
[]Case-sensitive

This regular expression looks for:  
the string: xyz  
and any other character: .  
occuring 0 ore more times: \*  
or: |  
the string: 256  
and any other character: .  
occuring 0 ore more times: \*

and replace it with  
the string: .mp3

If you have a filename like  
01-Artistname-Title of the 256 most fantastic songs.mp3  
you get  
01-Artistname-Title of the .mp3 \<--- have a look at the space after the word "the "!

If you have a filename like  
01-Artistname-Title (xyz and something else).mp3  
you get  
01-Artistname-Title (.mp3 \<--- have a look at the brace left from .mp3!

If you have a filename like  
256-Artistname-Title (xyz and something else).ogg  
you get  
.mp3 \<--- 256 and everything else will be replaced by the fixed .mp3!

You see, it isn't that easy with your definition "xyz or 256 and everything AFTER it in a filename".  
Even if you say: the extension isn't part of a filename, you still have the problem with spaces, braces and the position of "xyz" and "256".

Maybe it would be better, if you could give us some REAL examples of your filenames.

I hope, this will give you starting point. 🕶

---

<div class="post-metadata">

### Author: ![studley](https://community.mp3tag.de/user_avatar/community.mp3tag.de/studley/32/144_2.png) [@studley](https://community.mp3tag.de/u/studley)
#### Post date: [August 7, 2007, 5:18pm UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/5 "2007-08-07T17:18:20Z")

</div>

Thanks! This was exactly what I needed. I appreciate the time you spent in your extensive explanation. I learned something new and hopefully others will learn from this example as well.

I used to put tons of junk into my filenames but often started with the bitrate encoded. By doing this for 256 and 320 I will be able to remove most of the garbage then tag from my old filenames.

I didn't realize that it would truncate the file extension, as well, so you saved me much confusion there as well.

Cheers,  
David

---

<div class="post-metadata">

### Author: ![studley](https://community.mp3tag.de/user_avatar/community.mp3tag.de/studley/32/144_2.png) [@studley](https://community.mp3tag.de/u/studley)
#### Post date: [August 7, 2007, 6:48pm UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/6 "2007-08-07T18:48:02Z")

</div>

Is this

(\s320.\*)

The way to handle that leading space?

Do I use the parens if I'm only searching one string?

Thanks,  
David

---

<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: [August 7, 2007, 7:05pm UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/7 "2007-08-07T19:05:13Z")

</div>

Yes: \s looks for a "white space".  
And if you wanna match the space AND open parenthesis:  
(\s(320.\*)

In your case, the paranthesis are not really necessary. They just group the possible matches together.

(xyz._)|(256._) would give you a group1 and group2. This way, you could replace each group with different content or do something with the first group and something else with the second group. 😉

---

<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:20pm UTC](https://community.mp3tag.de/t/regex-remove-from-filename/5265/8 "2026-02-09T12:20:26Z")

</div>


