# Delete everything after given text

**URL:** https://community.mp3tag.de/t/delete-everything-after-given-text/69378
**Category:** Support
**Created:** [August 11, 2025, 1:18am UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378 "2025-08-11T01:18:47Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [August 11, 2025, 1:18am UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/1 "2025-08-11T01:18:47Z")

</div>

Hi All

I'm trying to tidy my filenames. You very kindly helped previously.

In the majority of my filenames I have a year in brackets. It's always in the form (19xx).

I'd like to run an action to identify the date where present in each filename and delete everything (in whatever format) that comes after it. Where no year is present the filename can be left as is.

For example

Aeolian Piano Roll - When You Love, Love, Love (1903)  
Agnes Kimball- My Best Girl And Me (1913) Edison Cylinder  
Agnes Kimball- Trio From Faust (1912) (Edison Cylinder)  
Agnes Lynn - Jazz Baby (1919)  
Aileen Stanley - Home Again Blues  
Aileen Stanley - I Love My Baby (My Baby) (1926) Victor-50  
Aileen Stanley - Sweet Indiana Home  
Alan Turner - As Long As The World (1908) (Edison Cylinder)  
Alan Turner - Till The Sands (1912) (Edison Cylinder)  
Alaxander Prince - Bonnie Scotland (1914) Victor-995  
Alaxander Prince - Catch Me (1913) Columbia-2814 (78664)  
Albert Benzler - Dearie (1906) Victor-35

Would become

Aeolian Piano Roll - When You Love, Love, Love (1903)  
Agnes Kimball- My Best Girl And Me (1913)  
Agnes Kimball- Trio From Faust (1912)  
Agnes Lynn - Jazz Baby (1919)  
Aileen Stanley - Home Again Blues  
Aileen Stanley - I Love My Baby (My Baby) (1926)  
Aileen Stanley - Sweet Indiana Home  
Alan Turner - As Long As The World (1908)  
Alan Turner - Till The Sands (1912)  
Alaxander Prince - Bonnie Scotland (1914)  
Alaxander Prince - Catch Me (1913)  
Albert Benzler - Dearie (1906)

Grateful for any advice 🙂

---

<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: [August 11, 2025, 5:59am UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/3 "2025-08-11T05:59:15Z")

</div>

The filename seems to be build as `%artist% - %title%.` So what is the content of your title-tagfield?

If it is with this unwanted content too:  
Do you want to keep it like this or do you **also** want to change it?  
If you want to change it too do this first.

If it is without this content, just rebuild the filename with the converter Tag→Filename:  
Format String: `%artist% - % %title%`

The recommended workflow is whenever it is possible:  
First change the content of the tags, then rebuild the filename from the tags.

---

<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 11, 2025, 6:13am UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/4 "2025-08-11T06:13:48Z")

</div>

@chayes  
You can either use an Action from the type "Replace with regular expression":  
_(please see my [updated answer](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/7) that keeps the file extension in an Action)_

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

**or for a better visual control**

You can use Convert "Tag - Tag" to see an immediate preview of your new filename  
**Field:**  
\_FILENAME  
**Format string:**  
`$regexp(%_FILENAME%,(^.*\(19\d\d\))(.*$),$1)`

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

---

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [August 11, 2025, 2:42pm UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/5 "2025-08-11T14:42:29Z")

</div>

Thanks [LyricsLover](https://community.mp3tag.de/u/lyricslover) - It’s working fine as an action , but removes the file extension too. Can it be modified to not delete the file extension?

---

<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: [August 11, 2025, 4:31pm UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/6 "2025-08-11T16:31:24Z")

</div>

What has happend to @poster 's idea to create the filename from tags?

> [@poster](#):
>
> The recommended workflow is whenever it is possible:  
> First change the content of the tags, then rebuild the filename from the tags.

---

<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 11, 2025, 5:09pm UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/7 "2025-08-11T17:09:27Z")

</div>

> [@chayes](#):
>
> It’s working fine as an action , but removes the file extension too.

Good catch. Only the Action is removing the filename extension.  
(Using Convert Tag-Tag does not remove the extension with above regular expression as you can see in the preview).

As an argument, I could say that the examples you gave has no file extension. 😉  
Just a joke...

For an Action "Replace with regular expression" that keeps the file extension, you could use:  
Regular Expression:  
`(^.*\(19\d\d\)).*\.(.*)`  
Replace matches with:  
`$1.$2`

 ![image](https://community.mp3tag.de/uploads/default/original/3X/c/8/c801147b9665694af1f0315316b08fc692799614.png)

---

<div class="post-metadata">

### Author: ![chayes](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@chayes](https://community.mp3tag.de/u/chayes)
#### Post date: [August 11, 2025, 7:38pm UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/8 "2025-08-11T19:38:30Z")

</div>

Thanks [LyricsLover](https://community.mp3tag.de/u/lyricslover) - this amendment correctly deletes text after the date and also maintains the file extension.

Many Thanks! 🙂

---

<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: [September 10, 2025, 7:38pm UTC](https://community.mp3tag.de/t/delete-everything-after-given-text/69378/9 "2025-09-10T19:38:42Z")

</div>

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