Is it possible to regex search filenames in a folder and append a string when indicated?

Hello,

I have a specific folder containing backups with a lot of redundancy. I would like to find all filenames ending with a space+integer and append the filename with -DUPLICATE to those filenames.

I thought I had the regex to do so, but I now realize that I am replacing instead of appending - DUPLICATE, so the regex is incorrect.
Regex ( \d)(?=.html)
Substitution \1 - DUPLICATE

For example if I had the files:

VPN new subscription choice of protocol and server 26 Aug 2020.html
VPN new subscription choice of protocol and server 26 Aug 2020 2.html
VPN new subscription choice of protocol and server 26 Aug 2020 3.html
VPN new subscription choice of protocol and server 26 Aug 2020 4.html

After running the macro, I would end up with:

VPN new subscription choice of protocol and server 26 Aug 2020.html
VPN new subscription choice of protocol and server 26 Aug 2020 2 -DUPLICATE.html
VPN new subscription choice of protocol and server 26 Aug 2020 3 -DUPLICATE .html
VPN new subscription choice of protocol and server 26 Aug 2020 4 -DUPLICATE.html

Is this possible ?

thank you!

Yep.

I would use:

SEARCH FOR:
(\d \d+)\.html

REPLACE WITH:
\1 - DUPLICATE.html

For details see regex101: build, test, and debug regex

1 Like

thank you !

1 Like