Add Parenthesis Around Year in Title with Multiple Numbers

If you need help on how to use the program
Post Reply
mjschulz
Posts: 1
Joined: 2016-06-15 19:03:55

Add Parenthesis Around Year in Title with Multiple Numbers

Post by mjschulz »

I'm trying to add parenthesis around the year in a folder full of movies that also have other numbers in the title or type.

For example, if I have the following two movies:

Good Movie 2008 [1080p BluRay].mp4
1984 1984 [1080p BluRay].mp4

I want to rename them to:

Good Movie (2008) [1080p BluRay].mp4
1984 (1984) [1080p BluRay].mp4

I've been working with the following regular expression, but it add parenthesis around the 1080 rather than the year.
Expression: ^(.*)([0-9]{4})(.+)$
New Name: $1($2)$3

Any help would be greatly appreciated.
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

You may prefix the expression by (?-g) to make groups work in non-greedy mode, i.e. they'll take less possible instead of most possible.
It seems to work in this particular example, check if that can applied to all your title cases.
So:
(?-g)^(.*)([0-9]{4})(.+)$
or
^((?-g).+)([0-9]{4})(.+)$
if you only want to apply that to the first group (in case it cause other problems in more complex expressions)
Post Reply