Add space after/before parentheses without changing the rest

Bulk Rename Utility How-To's

Add space after/before parentheses without changing the rest

Postby Guy » Tue Nov 21, 2023 11:03 am

Hi,

I have many folders in Windows with names and then parentheses, the date, and again closed parenthesis, like below:

A (1999)
B (2005)
C (1987)
D (1956)
and so on,....and now I'd like to add a "space" after and before those "parentheses to be like these:

A ( 1999 )
B ( 2005 )
C ( 1987 )
D ( 1956 )

But among those folders, some folders have spaces before their parentheses and applied before, so they shouldn't be affected, just need spaces for those that haven't spaces after and before parentheses.
Guy
 
Posts: 16
Joined: Wed Jan 19, 2022 8:27 am

Ending (year) --> ( year )

Postby Luuk » Tue Nov 21, 2023 12:42 pm

With RegEx(1) having a checkmark for "v2", the "Match" and "Replace" can be like...
^(.+ \()(19\d\d|20\d\d)(\))$
$1 $2 $3

If the folder-names only have 1-english uppercase letter before (year)...
^([A-Z] \()(19\d\d|20\d\d)(\))$
$1 $2 $3
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: Ending (year) --> ( year )

Postby Guy » Tue Nov 21, 2023 3:41 pm

Luuk wrote:With RegEx(1) having a checkmark for "v2", the "Match" and "Replace" can be like...
^(.+ \()(19\d\d|20\d\d)(\))$
$1 $2 $3


Great job Luuk, it works well and renamed them immediately as wished! :mrgreen:
Guy
 
Posts: 16
Joined: Wed Jan 19, 2022 8:27 am

Re: Add space after/before parentheses without changing the rest

Postby therube » Tue Nov 21, 2023 5:08 pm

If you know that your names only contain "years" within parenthesis (rather then some random data - like (random data) within parenthesis), then you can use something like:

3:Replace
Code: Select all
Match:  (|)
Replace:  ( | )

The | is an OR, so match will find, "(" OR ")" & with that, you're replacing any "(" with "( " and any ")" with " )".
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Add space after/before parentheses without changing the rest

Postby Guy » Wed Nov 22, 2023 1:17 pm

therube wrote:If you know that your names only contain "years" within parenthesis (rather then some random data - like (random data) within parenthesis), then you can use something like:

3:Replace
Code: Select all
Match:  (|)
Replace:  ( | )

The | is an OR, so match will find, "(" OR ")" & with that, you're replacing any "(" with "( " and any ")" with " )".


Cool, didn't know 3:Replace section can do that with simple "|" character! Thank you bro. :wink:
Guy
 
Posts: 16
Joined: Wed Jan 19, 2022 8:27 am


Return to How-To