Regexp in Batch Rename

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
User avatar
SvA
Posts: 486
Joined: 29 Mar 2006, 02:41
Location: DE

Regexp in Batch Rename

Post 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.
User avatar
SelfMan
Posts: 1155
Joined: 05 Apr 2006, 20:51
Contact:

Re: Regexp in Batch Rename

Post by SelfMan »

Hmm and how about
Search: (.*\.\w+)\.(\w+)
replace: $1
User avatar
Ether
Posts: 1471
Joined: 10 May 2007, 16:08
Location: Czech Republic
Contact:

Re: Regexp in Batch Rename

Post 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).
Ελληνικά rulez.
User avatar
SvA
Posts: 486
Joined: 29 Mar 2006, 02:41
Location: DE

Re: Regexp in Batch Rename

Post 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.
Petr Solin
ALTAP Staff
ALTAP Staff
Posts: 1112
Joined: 08 Dec 2005, 09:13
Location: Novy Bor, Czech Republic
Contact:

Re: Regexp in Batch Rename

Post 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.
User avatar
SelfMan
Posts: 1155
Joined: 05 Apr 2006, 20:51
Contact:

Re: Regexp in Batch Rename

Post 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.
Post Reply