Remove pattern at end of Text

Advanced Renamer forum
#1 : 26/05-20 17:37
Steve
Steve
Posts: 1
i think what i am trying to do is similar to
https://www.advancedrenamer.com/forum_thread?for um_id=6776

but i still need help

i have files that end with
TV SHOW - ETCETC 2020_05_19_18_30_00.txt

i want to remove the date portion and just have
TV SHOW - ETCETC.txt

however the date is not always added to my files so i cannot simply use the remove function to remove the last 20 characters etc.

i need a way to say Remove if it has the Date/time info at the end. ignore if it does not.


any thoughts?



26/05-20 17:37
#2 : 27/05-20 06:34
David Lee
David Lee
Posts: 473
Not just similar - your problem is identical in principal to the one in the thread that you mention and the solution is the same: use a regular expression to match the date string if it occurs at the end of a filename.

Re-read my previous explanation and the User Guide section:
www.advancedrenamer.com/user_guide/regular_expresions

In your case you don't have the advantage of parentheses to identify the string to remove, so you will have to define the date string itself.

Use the regular expression: " \d{4}(_\d{2}){5}$" (don't include the quotes).

You can use this in the Replace method, as in the previous solution, or more simply in the Remove pattern method.

The regex matches a space followed by four digits then five repetitions of an underscore and two digits, with the "$" indicating that the entire pattern must occur at the end of the filename.


27/05-20 06:34