Movie format with collections issue
Posted: 25 Sep 2016, 08:27
FileBot is fantastic, and has already saved me a bunch of time. I successfully renamed my ripped TV Shows library, and have moved onto my ripped movies library. @rednoah you have come up with an amazing tool that is supported by what seems to be a great community. Thank you so much!
I have been working on a comprehensive naming scheme for a couple weeks now, and have hit a wall. I got 90% of it working, but cannot for the life of me figure out how to incorporate collections in the way that I would like, listing movies inside a collection in order of the year released.
I want the end product inside a collection to look thusly (differences in orange):
The below never works with a collection, and only renames the movies to the {ny} format in my directory structure:
The below gets the folders correct, but does not have the year before the name like I want it to:
I have tried a more complicated version, but keep getting groovy errors:

and:

My full code is here, and I'm sure contains many errors inside the collection code (it works well when I take that portion out):
gives this error:

Here is my working format, but without the modified collection parameters so movies inside a collection are listed by year:
I read through quite a few forum posts on formats (DrevXen's, Ithiel's, and quite a few others). I've tried to figure out how to use "if/then" statements from all the code examples on the forums, but it seems I have not yet grasped how to do this in groovy. I even went to groovy-lang.org and tried to get the format from there with no success.
I know all this outs me as quite the newbie, but hopefully I can learn from this if you are able to help! Sorry for the long post, hopefully I have adequately described the issue and my goals with the proposed code.
-edited for image posting issue
I have been working on a comprehensive naming scheme for a couple weeks now, and have hit a wall. I got 90% of it working, but cannot for the life of me figure out how to incorporate collections in the way that I would like, listing movies inside a collection in order of the year released.
I want the end product inside a collection to look thusly (differences in orange):
- M:\Videos\Movies\Avatar Collection\[2009] Avatar [PG-13]\Avatar [2009] - [PG-13][161 Min][720p x264 AC3 5.1ch].mkv
- M:\Videos\Movies\Avatar [2009][PG-13]\Avatar [2009] - [PG-13][161 Min][720p x264 AC3 5.1ch].mkv
The below never works with a collection, and only renames the movies to the {ny} format in my directory structure:
Code: Select all
M:/Videos/Movies/{any {collection/{y} {n}/{ny}} {ny/ny}}
Code: Select all
M:/Videos/Movies/{any {collection/ny/ny} {ny/ny}}

and:

My full code is here, and I'm sure contains many errors inside the collection code (it works well when I take that portion out):
Code: Select all
{any
{if (file.path.lower().matchAll(/(3d|half|full|h?sbs|f?sbs|(?i)(?<=^|[^a-z])hou(?=$|[^a-z])|(?i)(?<=^|[^a-z])fou(?=$|[^a-z])|f.ou|anaglyth)(?:.sbs|(?i)(?<=^|[^a-z])cat(?=$|[^a-z]))?/))
{'M:/Videos/Movies-3D]/'}}
{'M:/Videos/Movies/'}}
{if (collection)
{{collection.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}/
{if (y) {' ['+y +']'}}
{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}
{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','').replaceAll(/^ \d+$/, 'PG-$0')}/}
{{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}
{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}
{if (y) {' ['+y +']'}}
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','').replaceAll(/^ \d+$/, 'PG-$0')}/}}
{(n)}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}
{fn.contains('Extended') || fn.contains('EXTENDED') || fn.contains('extended.cut') ? ' (Extended)' : fn.contains('Special Edition') || fn.contains('SPECIAL EDITION') || fn.contains('SPECIAL.EDITION') ? ' (Special Edition)' : fn.contains('Unrated') || fn.contains('UNRATED') ? ' (Unrated)' : fn.contains('Uncensored') || fn.contains('UNCENSORED') ? ' (Uncensored)' : fn.contains('Remastered') || fn.contains('REMASTERED') ? ' (Remastered)':""}
{if (y) {' ['+y +']'}}
{" Part $pi"} -
{any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','').replaceAll(/^ \d+$/, 'PG-$0')}
{"[$minutes Min]"}
{"[$vf $vc $ac "+af.replace('8ch', '7.1ch').replace('7ch', '6.1ch').replace('6ch', '5.1ch').replace('3ch', '2.1ch').replace('2ch','2.0ch')+"]"}
.{cf}

Here is my working format, but without the modified collection parameters so movies inside a collection are listed by year:
Code: Select all
M:/Videos/Movies/
{collection.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}/
{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}
{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}
{if (y) {' ['+y +']'}}
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','NR').replaceAll(/^ \d+$/, 'PG-$0')}/
{(n)}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}
{fn.contains('Extended') || fn.contains('EXTENDED') || fn.contains('extended.cut') ? ' (Extended)' : fn.contains('Special Edition') || fn.contains('SPECIAL EDITION') || fn.contains('SPECIAL.EDITION') ? ' (Special Edition)' : fn.contains('Unrated') || fn.contains('UNRATED') ? ' (Unrated)' : fn.contains('Uncensored') || fn.contains('UNCENSORED') ? ' (Uncensored)' : fn.contains('Remastered') || fn.contains('REMASTERED') ? ' (Remastered)':""}
{if (y) {' ['+y +']'}}
{" (Part ${pi.pad(2)})"} -
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','NR').replaceAll(/^ \d+$/, 'PG-$0')}
{" [$minutes Min]"}
{" [$vf $vc $ac "+af.replace('8ch', '7.1ch').replace('7ch', '6.1ch').replace('6ch', '5.1ch').replace('3ch', '2.1ch').replace('2ch','2.0ch')+"]"}
.{cf}
I know all this outs me as quite the newbie, but hopefully I can learn from this if you are able to help! Sorry for the long post, hopefully I have adequately described the issue and my goals with the proposed code.
-edited for image posting issue