Filename Cleanup Using Only RegEx in BRU (Simple OFF, v2 OFF

A swapping-ground for Regular Expression syntax

Filename Cleanup Using Only RegEx in BRU (Simple OFF, v2 OFF

Postby elewan9 » Tue Jul 15, 2025 9:02 am

Only Using REGEX(without using replace (3) or remove (4), charater translation etc.

(currently simple is unchecked, v2 unchecked) in bulk rename utility version 4.0.0.8

rename=
Code: Select all
!!k$h!t @nd Ra~~```hul..........Propo$..-..ed___-____ H__-erWearing Cr!cket Jersey[])(][)(}}{{[][Wedding](M@nd@p) {Gulabjamun}[Flew Barat.mkv


into=
Code: Select all
Iikshit And Rahul Proposed Her Wearing Cricket Jersey Wedding Mandap Gulabjamun Flew Barat.mkv


(reg ex should be able to clean such type of names).
elewan9
 
Posts: 3
Joined: Tue Jul 15, 2025 8:49 am

Using /g and (?X) for multiple replacements

Postby Luuk » Wed Jul 16, 2025 4:05 am

Since its many different replacements, should put the checkmark inside for "v2".
Then can use /g to say "global, so then a "Match" and "Replace" something like...

!/g(?X)@/g(?X)\$/g(?X)[][{}()~`._-]+/g(?X)([a-z])([A-Z])/g(?X)(^| )(.)/g
i(?X)a(?X)s(?X)(?X)$1 $2(?X)$1\u$2

If needing to remove other-characters, can add them into the underlined-characters before "-".
Luuk
 
Posts: 833
Joined: Fri Feb 21, 2020 10:58 pm

Re: Filename Cleanup Using Only RegEx in BRU (Simple OFF, v2 OFF

Postby elewan9 » Mon Aug 04, 2025 7:28 pm

thank you so much..

before=
Code: Select all
!!k$h!t @nd Ra~~```hul..........Propo$..-..ed___-____ H__-erWearing Cr!cket Jersey[])(][)(}}{{[][Wedding](M@nd@p) {Gulabjamun}[Flew Barat.mkv


after=
Code: Select all
Iikshit And Rahul Proposed Her Wearing Cricket Jersey Wedding Mandap Gulabjamun Flew Barat.mkv




if i had to also truncate filename length (lets say to 75 characters max, excluding extension), how would these be modified???

match=
Code: Select all
!/g(?X)@/g(?X)\$/g(?X)[][{}()~`._-]+/g(?X)([a-z])([A-Z])/g(?X)(^| )(.)/g


replace=
Code: Select all
i(?X)a(?X)s(?X)(?X)$1 $2(?X)$1\u$2


(v2 on, simple off)
elewan9
 
Posts: 3
Joined: Tue Jul 15, 2025 8:49 am

Re: Filename Cleanup Using Only RegEx in BRU (Simple OFF, v2 OFF

Postby elewan9 » Mon Aug 04, 2025 8:17 pm

Please ignore last messege.

So i tested on another file names, it fails. sadly. beyond my capacity to fix it. (i am also truncating filename at 75)
case1= DESIRED RESULT
before=
Code: Select all
!!k$h!t @nd Ra~~```hul..........Propo$..-..ed___-____ H__-erWearing Cr!cket Jersey[])(][)(}}{{[][Wedding](M@nd@p) {Gulabjamun}[Flew Barat.mkv

after=
Code: Select all
Iikshit And Rahul Proposed Her Wearing Cricket Jersey Wedding Mandap Gulabj.mkv


case2==> UNWANTED RESULT

before=
Code: Select all
WiTh.the_Swords  __  Under   Gr@nd_$eMe$ter....Arr!ves__a an the of--_In_S!lence--..Two____Fu!!ll_Moon[]{}()~~~Of_Mount!ain_R!tuals  .mkv


after=
Code: Select all
Wi Ththe Swords    Under   Grandse Mester Arrivesa An The Of In Silence Two.mkv


Here’s the ideal truncated version (75 characters max) of case 2 filename:-
Code: Select all
With The Swords Under Grand Semester Arrives A An The Of In Silence Two Full.mkv


((((problems in case2=The following issues occur with the current regex cleanup:

1. "WiTh.the" becomes "Wi Ththe" instead of "With The" — the period is removed without inserting a space.
2. "Gr@nd_$eMe$ter" becomes "Grandse Mester" but "$" is inconsistently replaced, sometimes duplicated or misplaced.
3. "Arr!ves__a" becomes "Arrivesa" instead of "Arrives A" — the words get merged due to multi-symbol deletion.
4. Multiple underscores like "__" and "____" remove separation between words, causing words to merge or collapse.
5. Double or triple spaces (e.g., after "Swords" or "Under") are preserved instead of being normalized to a single space.
)))

case 3= getting unwanted result
before=
Code: Select all
A.Stranger.by.the.Hill.{2024}.[1080p].10bit.IT.WEBRip.(Hindi).DD5.1.x265.HEVC-Ospreay.mp4


after=
Code: Select all
AStrangerbythe Hill20241080p10bit ITWEBRip Hindi DD51x265HEVCOspreay.mp4


ideal output=
Code: Select all
A Stranger By The Hill 2024 1080p 10bit IT Webrip Hindi DD5 1 x265 Hevc Ospreay.mp4


case 3 problems=1. Dots (.) between words like "A.Stranger.by.the.Hill" are removed without being converted to spaces, causing merged words.
2. Braces {}, brackets [], and parentheses () are stripped without spacing, leading to glued words like "Hill2024".
3. No space is added between year and resolution, causing "20241080p" instead of "2024 1080p".
4. Uppercase-lowercase transitions like "ITWEBRip" are not properly separated into "IT WEBRip".
5. No consistent spacing between elements like "Hindi", "DD5.1", "x265", etc., reducing readability.


currently using in bru=

search=
Code: Select all
!/g(?X)@/g(?X)\$/g(?X)[][{}()~`._-]+/g(?X)([a-z])([A-Z])/g(?X)(^| )(.)/g(?X)^(.{75}).*


replace=
Code: Select all
i(?X)a(?X)s(?X)(?X)$1 $2(?X)$1\u$2(?X)$1



bru version= 4.0.1.0
elewan9
 
Posts: 3
Joined: Tue Jul 15, 2025 8:49 am


Return to Regular Expressions


cron