Delete everything after given text

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 :slight_smile:

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.

@chayes
You can either use an Action from the type "Replace with regular expression":
(please see my updated answer that keeps the file extension in an Action)

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)

Thanks LyricsLover - It’s working fine as an action , but removes the file extension too. Can it be modified to not delete the file extension?

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

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. :wink:
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

Thanks LyricsLover - this amendment correctly deletes text after the date and also maintains the file extension.

Many Thanks! :slight_smile: