Regex for renaming movie titles

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

Regex for renaming movie titles

Postby Mummraah » Thu Jan 19, 2023 9:49 pm

Hi

I'm looking to rename movie files. They come in the following naming convention:

'Aladdin.1992.PROPER.1080p.BluRay.x265.mp4'

I would like to use regex or some way to automate the naming to

title (year) so the above would become 'Aladdin (1992).mp4'

Struggling to find a solution as some movies have years in the title, eg 1917, 2001 A space Odyssey, Wonder Woman 1984 which complicates things.

Any help would be greatly appreciated.
Mummraah
 
Posts: 2
Joined: Thu Jan 19, 2023 9:43 pm

Re: Regex for renaming movie titles

Postby therube » Mon Jan 23, 2023 6:19 pm

If the titles are "dot" separated (& if the name part itself does not have dots, & if the names are in name | date | anything else order)...

1:RegEx, simple
Code: Select all
Match:  %1.%2.%3
Replace:  %1 (%2)


Match the "name"
Match the "year" (& place it in parens)
Ignore all else (i.e. %3) [If you wanted it, add a %3 in the Replace: box.]


If the filename uses spaces instead of dots... that would be different.
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Regex for renaming movie titles

Postby Mummraah » Thu Jan 26, 2023 5:12 pm

Thank you for the response.

That does work but only with single title films. For films with more than a single word in the name eg:

Out.of.Africa.1985.REMASTERED.1080p.BluRay.x265 becomes Out (of)

or

The.Hurt.Locker.2008.1080p.Webrip.h265 comes out as: The (Hurt)

I'm managing to do this at the moment in 5 steps.

1. Replace (3) . with ' '

2. Remove everything after 1080p with RegEx (1)
Code: Select all
(.*1080p)
\1

3. Remove ' 1080p' either with Replace (3) and the replace empty or Remove (5) last n 6

4. Remove everything after the year which is now the last 4 digits with RegEx (1)
Code: Select all
(.*\d+)(?!.*\d)
\1

5. Use Add (7) Inset ( at pos -4 and suffix )


The regex to get it more efficient is beyond me. Couple of bits though. The year is always the last 4 digits before 1080p everything prior to the 4 year digits is the title. Everything between the year and 1080p is not required, everything after the 1080p can differ but is not required.

I should add I am looking to do this in bulk and it could be as many as significant numbers of files at a time. My aim would get something to do it in one pass regardless of length of film name.
Mummraah
 
Posts: 2
Joined: Thu Jan 19, 2023 9:43 pm


Return to BRU Support


cron