Page 1 of 1

Regexp in Batch Rename

Posted: 22 Jul 2013, 16:42
by SvA
I just happened to stumble uppon a strage behaviour in the Batch Rename plugin.
I had a couple of files with extensions resembling a GUID, something like

Code: Select all

access.idl.29D3591E_F1C6_40AF_BCC6_7FC8BBE50B30
I wanted to remove those extensions and created a regular expression in the Search for field with the Replace with field being empty. Since the regexp engine does not support numbered repetition (something like {8} or {0,8}) the regexp grew rather long:

Code: Select all

\.[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]_[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]_[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]_[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]_[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]
With the addition of the last hex digit ([0-9A-Z]) the New Name field turned from access.idl0 to <Regular expression error: Unmatched [].>

Did the regexp grow too long or is there some other error in the regexp machine?

If the expression was too long, please indicate clearly, or limit the length of textbox control.

I replaced that last [0-9A-Z] with .$, which fitted my bill.

Re: Regexp in Batch Rename

Posted: 22 Jul 2013, 22:05
by SelfMan
Hmm and how about
Search: (.*\.\w+)\.(\w+)
replace: $1

Re: Regexp in Batch Rename

Posted: 23 Jul 2013, 08:25
by Ether
I guess the code was designed with the 260 MAX_PATH limit in mind. I vote for extending the limit (on other places also, like in the Containing field in Find).

Re: Regexp in Batch Rename

Posted: 23 Jul 2013, 20:05
by SvA
SelfMan wrote:Hmm and how about
Search: (.*\.\w+)\.(\w+)
replace: $1
This regexp matches many files that it shouldn't but on the other hand it does not match many it should.

But the intention of this post was not to get help finding a regexp that worked, but pointing out a glitch in AS that Altap might want to correct at some point.

Re: Regexp in Batch Rename

Posted: 24 Jul 2013, 16:56
by Petr Solin
Thanks for finding this bug! There was incorrectly limited length of text, so you can enter more than 260 characters, but only 260 characters is used.

I have fixed it, so you cannot enter more text than it really uses. And I have also doubled length limit for this edit box (now it is 520 characters).

This fix will be available in next version.

Re: Regexp in Batch Rename

Posted: 25 Jul 2013, 02:06
by SelfMan
SvA wrote:
SelfMan wrote:Hmm and how about
Search: (.*\.\w+)\.(\w+)
replace: $1
This regexp matches many files that it shouldn't but on the other hand it does not match many it should.

But the intention of this post was not to get help finding a regexp that worked, but pointing out a glitch in AS that Altap might want to correct at some point.
weird, because I've tested it on the mentioned example and it worked. I am not saing its perfect tho.
I ment this as a workaround untill a fix is available.