Help with a RegEx move rename

Advanced Renamer forum
#1 : 17/06-20 23:22
Richard Morris
Richard Morris
Posts: 2
Good morning,

I am new to the forum and have "lurked" and searched for similar problems and solutions but to no avail. Could anyone help me with the scenario below?

I am trying to rename a file by searching for (variable) text within the filename, and moving that text to the end of the filename.

Original: @@Company Name and WDC some changing text@Lease@Correspondance@01011990@16071990@04062020.pdf

New:@@Company Name and WDC@Lease@Correspondance@01011990@16071990@04062020@ some changing text.pdf

I'm thinking a regex to select all text after "WDC" but before the next "@" symbol, which I want to move to the end of the filename.

I think I have the regex sorted:


But I can't seem to get it to operate in ADREN - mostly because I don't know what I'm doing.

If anyone could offer some advice on this it would be very much appreciated.


17/06-20 23:22
#2 : 18/06-20 08:51
David Lee
David Lee
Posts: 473
Hi Richard

"Lookbehind" is not available in the implementation of RegEx used in Advanced Renamer and ARen is interpreting the "<" as the beginning of a tag and so throws an error.

An alternative to Lookbehind is the metacharacter \K which means forget the previous part of the match.

Lookahead is implemented, so the Regex .*WDC\K(.*?)(?=@) will work, in the sense that it will select the correct portion of text and save it to a variable.

However, this won't help in a Replace method, since all you can do is replace or remove the text and you want to move it to the end of the filename.

What you need to do is also save the text before and after your selection into additional variables and rearrange them in the replacement string.

Replace method...
Text to be replaced: (.*WDC)(.*?)(@.*)
Replace with: \1\3@\2

18/06-20 08:51
#3 : 19/06-20 00:43
Richard Morris
Richard Morris
Posts: 2
Reply to #2:

Aha! That's where I was going wrong.

OK - all good now - thank you for your help.


19/06-20 00:43