Mystery of the disappearing parentheses ...

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Mystery of the disappearing parentheses ...

Postby MyTimeNow » Thu Sep 03, 2026 10:42 pm

I apologize if this is a repeat question, but I couldn't find anything using advanced search.
I asked the RegEx assistant, the following:

I gave the BRU AI the following challenge:

My movie folders each contain a movie and it's related sidecar files. I want to rename the base name of all the content files to the folder name.

This is a sample movie folder name:
"Some Old Movie (1936)\"

This is a sample of folder content:
"
[i]SomeMovie (1936).English.srt
SomeMovie (1936).mp4
SomeMovie (1936)-mediainfo.xlm
SomeMovie (1936)-portrait.jpg
SomeMovie (1936)-trailer.mp4
[/i]
"
Notice how the movie sub-folder and the base file name each end in in a year enclosed in parentheses "\(\d{4}\)". This will make identifying the titles easy.

Here are the results I expected:
"
[i]SomeMovie (1936).English.srt ? Some Old Movie (1936).English.srt
SomeMovie (1936).mp4 ? Some Old Movie (1936).mp4
SomeMovie (1936)-mediainfo.xlm ? Some Old Movie (1936)-mediainfo.xlm
SomeMovie (1936)-portrait.jpg ? Some Old Movie (1936)-portrait.jpg
SomeMovie (1936)-trailer.mp4 ? Some Old Movie (1936)-trailer.mp4
[/i]"
I've tried the following in regular expressions RegEX(1) on the advice of the BRU assistant from an earlier visit:

Match: "^.*?(\(\d{4}\))(.*)$"
Replace: "<folder>$2"


These are my actual results:
"
SomeMovie (1936).English.srt ? Some Old Movie 1936.English.srt
SomeMovie (1936).mp4 ? Some Old Movie 1936.mp4
SomeMovie (1936)-mediainfo.xlm ? Some Old Movie 1936-mediainfo.xlm
SomeMovie (1936)-portrait.jpg ? Some Old Movie 1936-portrait.jpg
SomeMovie (1936)-trailer.mp4 ? Some Old Movie 1936-trailer.mp4
"

Please note that the parentheses have been removed in the results. Why are they removed and how can I correct it at the same time as the rename task runs? When I asked the assistant again, I explained this error and asked why it happened and how to correct it at the same time as the rename. The RegEx assistant did a deep think and basically told me it should work, that I probably had a filter or translation removing the parentheses.

I did a reset and typed in the regex stuff again. When I tried running it again, the date portion still DID NOT include the parentheses. I searched through all the settings to verify I had no filters or translations that got missed. Nothing explains this. I have used the RegEx assistant several times and it is usually spot on in its recommendations.

I tried using "Append Folder Name(9)" and the appended name DOES INCLUDE the parentheses. This is not ideal since it would leave me an additional renaming task to perform to make the sidecar files correct again.

Can anyone on the development team explain why this happens and a work around for it?

Also, I searched the manual and the Expert's corner manual and found no mention of using <folder> at all. Did I mess that? Where did the assistant get that information?

Thank you for your time and effort!

Have a good day.
MyTimeNow
 
Posts: 9
Joined: Fri Oct 28, 2022 6:04 am

Re: Mystery of the disappearing parentheses ...

Postby therube » Fri Sep 04, 2026 5:18 pm

(Without looking to understand why ... ;-))

If you were to escape either or both of the un-escaped ( ), then it should work.

Existing:
Code: Select all
^.*?(\(\d{4}\))(.*)$


Revised:
Code: Select all
^.*?\(\(\d{4}\))(.*)$
^.*?(\(\d{4}\)\)(.*)$
^.*?\(\(\d{4}\)\)(.*)$
therube
 
Posts: 1488
Joined: Mon Jan 18, 2016 6:23 pm

Re: Mystery of the disappearing parentheses ...

Postby MyTimeNow » Fri Sep 04, 2026 10:28 pm

therube wrote:If you were to escape either or both of the un-escaped ( ), then it should work.


I wish it was that easy! My RegEx(1) match code is right as verified in the preview, it's the call to <folder> (also verified in the preview) that produces the elimination of the "()" characters.

If you'll notice in my original post, both the file names and the folder name contain the year enclosed in parentheses, yet the folder name (which I can't edit using <folder>), arrive sans parentheses. It's like I had a character translation to remove the "(" and ")". The only trouble is, everything has been reset and the code typed back in from scratch. I didn't even cut & paste the codes to be certain it was a clean copy. Aside from the disappearing "()" symbols, the output is right.

When I asked the RegEx assistant, I got this reply:

"If the preview still shows `Some Old Movie 1936` without parentheses, then the folder value being returned is itself missing the parentheses, or another active renaming rule is removing them. Check the actual folder name and disable other active panels, especially Replace, Remove, or Case. With `<folder>` returning `Some Old Movie (1936)`, the regex above preserves the parentheses automatically."

I know I'm not imagining the result, so, I have clearly stumped the RegEx assistant.

I found other ways to do the same thing, such as removing the base name only and then using Append Folder Name (9) to put the folder name in its place. I've also written a JScript program to do the same in a single task, the way I wanted to do with the RegEx (1). Now its just a curiosity as to why this happens. I suspect its a bug and I'm the first one to discover it.

The other thing is, since <folder> is NOT in either manual, I'm curious as to how many other useful things are omitted from the manuals.

Thank you for taking the time to read and respond to my original posting. :)

Have a great day,
Mike
MyTimeNow
 
Posts: 9
Joined: Fri Oct 28, 2022 6:04 am

Re: Mystery of the disappearing parentheses ...

Postby TheGhost78 » Sat Sep 05, 2026 1:30 pm

Here's a workaround.

Match: ^.*?(\(\d{4}\))(.*)$(?X)^(.+? )(\d{4}\))

Replace: <folder>)$2(?X)\1 (\2
TheGhost78
 
Posts: 278
Joined: Fri Jul 19, 2024 11:25 am

Re: Mystery of the disappearing parentheses ...

Postby TheGhost78 » Sat Sep 05, 2026 1:55 pm

<folder> retains
[
]
{
}
but not
(
or
)

Presumably that's a bug.
TheGhost78
 
Posts: 278
Joined: Fri Jul 19, 2024 11:25 am

Re: Mystery of the disappearing parentheses ...

Postby MyTimeNow » Sun Sep 06, 2026 9:10 pm

TheGhost78 wrote:Here's a workaround.

Match: ^.*?(\(\d{4}\))(.*)$(?X)^(.+? )(\d{4}\))

Replace: <folder>)$2(?X)\1 (\2


Beautiful! That solved it! Thank you!!

Have a great day!
MyTimeNow
 
Posts: 9
Joined: Fri Oct 28, 2022 6:04 am


Return to BRU Support


cron