Page 1 of 1

Delete all digits at END of filename only

PostPosted: Mon Aug 29, 2022 9:19 pm
by w945106
I need to delete all non-alphabetic characters at the end of a file name (after a string of words) without deleting digits at the beginning of the filename.

20040315_093300_13_SkiTrip_Steamboat_200403_016.jpg => 20040315_093300_13_SkiTrip_Steamboat.jpg
20040606_210400_1433_LegoLand_SanDiego_200406_0016.tif => 20040606_210400_1433_LegoLand_SanDiego.tif

I want to delete everything after the last alphabetical character in the filename, leaving the .extension intact.

Thank you.

Delete characters at end of filename

PostPosted: Tue Aug 30, 2022 12:26 am
by Luuk
To delete everything after the last english letter, RegEx(1) can use a "Match" and "Replace" like...
(.*[A-Za-z]).*
\1

To delete everything after any last letter including unicodes, put a checkmark for "v2", so then more like...
^(.*(?![\d_])\w).*
$1

To delete underscores and digits from the end, "v2" uses a Match like...
[\d_]+$

To delete all strings of "_digits" from the end, "v2" uses a Match like...
(\d_+)+$

Re: Delete all digits at END of filename only

PostPosted: Tue Aug 30, 2022 4:07 pm
by w945106
That worked perfectly.

Thank you!

Delete characters at end of filename

PostPosted: Tue Aug 30, 2022 4:47 pm
by Luuk
Except I made a typo on the last example! My keyboard is dying, so Im conducting way too many copy/pasting.
To delete all strings of "_digits" from the end, "v2" should use a Match like...
(_\d+)+$