Remove all bracketed text after first set of bracketed text

A swapping-ground for Regular Expression syntax

Remove all bracketed text after first set of bracketed text

Postby NootNootPingu » Sun May 05, 2024 10:36 am

I have a lot of Japanese doujins and manga that I need to rename in order for them to match metadata correctly within in my lanraragi server. I do not really know how to explain what I want other than remove all bracketed text after the first instance of bracketed text.

Some examples of the files look like this

(COMIC1?13) [OrangeMaru (YD)] Skill Kyouka Kaikin + OrangeMaru Special 04 (FateGrand Order) [English] [N04h].zip

[Bad Mushrooms (Chicke III, 4why)] Mimimi (Toaru Kagaku no Railgun) [English] [Zaibatsu] [Colorized].zip

[Gatakomanchi (Komagata)] Manmaru Meido no Shihaisha-sama <<Goshujin-sama>> (Overlord) [English] [Digital].zip

[Aoin] The Escort and the Flower Girl (Final Fantasy 7) [English].zip

[Kakurenbo (Danimaru)] Batsu Game de Onee-san to | A Dare with an Onee-san (Amayakashi Onee-san ni Ochinchin o Torottoro ni Sarete Nukedasenai ~OneShota Sakusei Anthology~) [English] [RedLantern].zip

I would like to have only the authors name and publisher along with the tiles to be left after renaming, which would be the first instance of brackets.

The final product I would want to look like this

[OrangeMaru (YD)] Skill Kyouka Kaikin + OrangeMaru Special 04.zip

[Bad Mushrooms (Chicke III, 4why)] Mimimi.zip

[Gatakomanchi (Komagata)] Manmaru Meido no Shihaisha-sama.zip

[Aoin] The Escort and the Flower Girl.zip

[Kakurenbo (Danimaru)] Batsu Game de Onee-san to | A Dare with an Onee-san.zip

Basically I only need the text within the first [ ] and the title of the work but I cannot really figure out of way to do that easily can anyone help with this?
NootNootPingu
 
Posts: 2
Joined: Sun May 05, 2024 10:17 am

Crop before first [text] Remove all other [text] or (text)

Postby Luuk » Sun May 05, 2024 11:51 pm

No Windows application will rename anything with having the illegal characters like ?<>:/|\".
But for other names, RegEx(1) can use a checkmark for 'v2', with a Match and Replace like...
^[^[]*(\[[^]]*\])(?X)(\G(?!^)|^\[[^]]*\]).*?\K ?[[(][^][()]*[])]/g
$1(?X)

Related post: http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=3&t=6479
Luuk
 
Posts: 714
Joined: Fri Feb 21, 2020 10:58 pm

Re: Remove all bracketed text after first set of bracketed text

Postby NootNootPingu » Mon May 06, 2024 12:02 am

This worked perfectly thank you so much!
I am very new to RegEx and had no clue how to do this oddly specific type of thing

As for the illegal characters most of the doujins don't have anything like that usually I don't mind manually renaming a few

Again Thanks!
NootNootPingu
 
Posts: 2
Joined: Sun May 05, 2024 10:17 am


Return to Regular Expressions