In the multi-rename tool Pipe with RegEx does not work

English support forum

Moderators: white, sheep, Hacker, Stefan2

Post Reply
Winfried
Junior Member
Junior Member
Posts: 7
Joined: 2009-02-03, 08:16 UTC

In the multi-rename tool Pipe with RegEx does not work

Post by *Winfried » 2018-06-11, 08:41 UTC

Hi,

I have these file names:
123.456.678-12_draft_123.4567_productname_180606.pdf

The first number before the draft can also be different: 123456-12

Now I want to delete "draft_" and the date at the end of the file name “_180606”.
When I enter this in the multi-rename tool in the Search field, the correct parts of the file name are found:
draft_|(_[0-9]+\.pdf)
RegEx is activated.
When the Replace field is <Clear>, both parts before and after the Pipe character are deleted. This works as expected.

However, when I enter this in the Replace field, the found text in both parts is replaced:
|\.pdf
Both parts are replaced with this: |.pdf
The Pipe character is inserted, although according to the help this should be only a separator.
When I enter this in the Replace field, the replacement does not work either:
<Clear>|\.pdf
Replaced with this in both parts: <Clear>|.pdf
When I deactivate RegEx, the Pipe character works for Replacements.
When I deactivate RegEx and enter <Clear>|.pdf in the Replace field, <Clear> is entered in the first part.
Is this a bug or do I have to change anything?

Another option for my problem is:
Search: (draft_)(.+)(_[0-9]+)
Replace: $2
This works, but this does not explain why the Pipe character cannot be used for replacements with RegEx.

Thank you very much for your help!

Best regards

Winfried

User avatar
Stefan2
Power Member
Power Member
Posts: 2183
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 » 2018-06-11, 09:11 UTC

RegEx special chars as like '|' are only special signs in the search field.
In Replace box they are literal signs.




BTW for others:
without ticked RegEx box, the pipe -symbol can be used to separate several search&replace parts, like:
Search: ö|ä|ü
Replace oe|ae|ue





 

Winfried
Junior Member
Junior Member
Posts: 7
Joined: 2009-02-03, 08:16 UTC

Post by *Winfried » 2018-06-11, 09:27 UTC

Thank you very much for your fast reply!
Pitty that this is a limitation of the multi-rename tool/RegEx feature.

Best regards

Winfried

User avatar
Stefan2
Power Member
Power Member
Posts: 2183
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 » 2018-06-11, 09:27 UTC

You want to try to rename


FROM:
123.456.678-12_draft_123.4567_productname_180606.pdf
123456-12_draft_123.4567_productname_180606.pdf

TO:
123.456.678-12_123.4567_productname.pdf
123456-12_123.4567_productname.pdf



Am I correct ?



 

Winfried
Junior Member
Junior Member
Posts: 7
Joined: 2009-02-03, 08:16 UTC

Post by *Winfried » 2018-06-11, 09:29 UTC

Yes.
I did it now with:
Search: (draft_)(.+)(_[0-9]+)
Replace: $2

This worked.

User avatar
Stefan2
Power Member
Power Member
Posts: 2183
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 » 2018-06-11, 09:32 UTC

Well done.



My way:

FROM:
123.456.678-12_draft_123.4567_productname_180606.pdf
123456-12_draft_123.4567_productname_180606.pdf

TO:
123.456.678-12_123.4567_productname.pdf
123456-12_123.4567_productname.pdf

Use:
Search: ^(.+)draft_(.+)_\d+$
Replace: $1$2
[x]RegEx
[_]E




 

Post Reply