How to Enclose "Variable Literal" with Square Brackets

Bulk Rename Utility How-To's

How to Enclose "Variable Literal" with Square Brackets

Postby jarhtmd » Sat Jan 22, 2022 3:32 am

I have some files that contain the variable-literal "Pano(#)" somewhere in the filename, usually but not always, at the very end of the filename. The # is a variable length (1, 2 or 3) digit number. I want to change "Pano(#)" to "[Pano(#)]". In other words, I want to enclose Pano(##) within square brackets [ ].
Before:
xxxxxxx Pano(1) yyyyyy
xxxxxxx Pano(22)
xxxxxxx Pano(333)
After:
xxxxxxx [Pano(1)] yyyyyy
xxxxxxx [Pano(22)]
xxxxxxx [Pano(333)]
I tried . . .
RexEx 1 with "Simple" Enabled
then
Match: %1 Prefix Pano(%2)
Replace : %1 [Prefix Pano(%2)]
That worked great, EXCEPT everything following the inserted closing bracket ] is truncated.
jarhtmd
 
Posts: 36
Joined: Fri Oct 27, 2006 8:53 pm
Location: Maryland, USA

Re: How to Enclose "Variable Literal" with Square Brackets

Postby Luuk » Sat Jan 22, 2022 6:47 am

Without the checkmark in "Simple", can use a "Match" and "Replace" like...
(.+)(Pano\(\d{1,3}\))(.*)
\1[\2]\3

Or with putting a checkmark in "v2", can use a "Match" and "Replace" like...
(Pano\(\d{1,3}\))
[$1]
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: How to Enclose "Variable Literal" with Square Brackets

Postby jarhtmd » Mon Jan 24, 2022 5:14 am

Thanks so much, Luuk. Both ways resulted in exactly what I want. I have been away from BRU for way too long (for legitimate reasons); way back to v2.7.1.3 and have a lot of catch-up learning to do. The preview feature is a wonderful addition. I realized that I have some TPano(#) and VPano(#) scattered throughout my folders, but they can be fixed easily by follow up of simply replacing T[Pano and V[Pano with [TPano and [VPano.
Thanks again for you prompt and helpful reply.
jarhtmd
 
Posts: 36
Joined: Fri Oct 27, 2006 8:53 pm
Location: Maryland, USA


Return to How-To