Keep version in file names unchanged using wildcard

Advanced Renamer forum
#1 : 24/07-22 17:08
Posts: 2
Hello guys,

I have files with version in final of the names, ex:


I need to modify all initial text in a List Replace using wildcard (*) and keeping version unchanged.

Ex (animation*...* / magazine-*...* ):


Thank you!

24/07-22 17:08 - edited 24/07-22 17:13
#2 : 24/07-22 18:29
David Lee
David Lee
Posts: 1026
Use a regular expression instead of a simple wildcard.


Replace: animation.*-
with: whatever
Use regular expressions

This will replace everything beginning with "animation" up to and including the final instance of "-"

If you always want to keep the initial word then you can use...

Replace: animation\K.*-
with: -school-education-appuniversity-


In a regular expression "." matches any character and the modifier "*" is an instruction to repeat the match any number of times (including zero).

The meta-character "\K" is an instruction not to include preceding matched characters in the final match.

24/07-22 18:29
#3 : 25/07-22 14:51
Posts: 2
Reply to #2:

Thank you, man!! It Works !

But in some cases I have versions starting with a point "." instead a "-" eg:

How can I achieve the same result in this situation?

25/07-22 14:51
#4 : 25/07-22 16:13
David Lee
David Lee
Posts: 1026
Reply to #3:
Straightforward: Basically use "." instead of "-" as your separating character.

However it's a bit more complicated since you will have to match the first dot in the filename and also dots appear in the version number in all filenames which would lead to unwanted results in other filenames.

The solution is to match "." only if it is followed by a version number. For this we can use a "lookahead" in the regular expression" eg the expression "qwerty(?=uiop)" will match the string "qwerty" but only if it is followed by "uiop" and "uiop" will not be included in the final match.


Replace: animation\K.*\.(?=\d?\.\d?\.\d?)
with: -school-education-appuniversity.

will replace "animation-education.1.2.3" with "animation-school-education-appuniversity.1.2.3"

Note that "." in a regular expression indicates any character, so it has to be "escaped" as "\." in order to represent itself.

You can handle cases with either "." or "-" in a single expression as follows...

Replace: animation\K.*([-\.])(?=\d?\.\d?\.\d?)
with: -school-education-appuniversity\1

Here the expression [abcd] will match any character appearing in the brackets and placing the expression in parenthesis (ie "([-\.])") will save the result in a numbered variable (\1), which can be used in the replacement string.

25/07-22 16:13 - edited 25/07-22 16:35