This took a long time and is a mashup of several people on the forum's contribution, but I wanted to share my finished product.
Here's my movie renamer.
Code: Select all
E:\movies\{def cn = any{"$collection".replaceFirst(/^(?i)(The|A|An|Der|Die|Das)\s(.+)/, /$2, $1/)+"/"}{n.replaceFirst(/^(?i)(The|A|An|Der|Die|Das)\s(.+)/, /$2, $1/)}; cn =~ /^(?i)[a-z]/ ? cn[0] : '#'}\{collection.replaceFirst(/^(?i)(The|A|An|Der|Die|Das)\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|A|An|Der|Die|Das)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y})/{n.space('.').replaceAll(/[,!'`´‘’ʻ""“”]/, "")}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}{' (' + fn.matchAll(/extended|uncensored|remastered|unrated|uncut|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().join(', ').replaceAll(/[._]/, ".") + ')'}.{y}{".Part$pi.$vf.$vc.$ac.$af"}
- moves to folder
- assigns a single character alpha/numeric folder hierarchy, ignoring articles (The, An, A, etc.)
- assigns the single character based on whether or not a collection exists
- cleans up the name of the Collections a little
- puts a full character movie name as the folder under the Collection folder
- if no Collection folder exists then the movie name is a level higher
- cleans up special characters a little
- renames the file as "." separated with some special Character cleanup
- Capitalizes/lower cases letters appropriately
Here are some examples of the output:
- from Risen_2016_t01.mkv to \R\Risen (2016)\Risen.2016.[original].mkv
- from Maze_Runner_The_Scorch_Trials_2015_t00.mkv to \M\Maze Runner Collection, The\Maze Runner - The Scorch Trials (2015)\Maze.Runner.The.Scorch.Trials.2015.[original].mkv
- from 13_Hours_The_Secret_Soldiers_of_Benghazi_2016_t01.mkv to \#\13 Hours - The Secret Soldiers Of Benghazi (2016)\13.Hours.The.Secret.Soldiers.of.Benghazi.2016.[original].mkv
- from Ocean's_Eleven_2001_t00.mkv to \O\Ocean's Collection\Ocean's Eleven (2001)\Oceans.Eleven.2001.[original].mkv
- from The_Town_2010_t00.mkv to \T\Town, The (2010)\The.Town.2010.[original].mkv
- from Hail_Caesar!_2016.mkv to \H\Hail, Caesar! (2016)\Hail.Caesar.2016.[original].mkv
I have no idea how to write code, all I did was hobble together hours of forum examples, but hopefully this is useful to someone that knows what they're doing.
Now I just have to figure out how to automate the script.
