How to add "Part_X" to end of filename for multipart files
Posted: 10 Mar 2021, 18:05
Hello and thanks in advance for any assist. I've done my best to find the answer to this among the trove of invaluable advice and examples in the forums, but alas I have failed.
I have a movie naming scheme that I am happy with, borrowed and plagiarized extensively and shamelessly from others' examples.
This results in output like this:
[*]101 Dalmatians II - Patch's London Adventure (2003) (Animation) (G) {imdb-tt0324941}/101 Dalmatians II - Patch's London Adventure (2003) (Animation) (G) [ENG] (BluRay 1080p) (AC3 5.1) (x265)
[*]Escape Plan 2 - Hades (2018) (Action) (R) {imdb-tt6513656}/Escape Plan 2 - Hades (2018) (Action) (R) [ENG] (BluRay 720p) (DTS 5.1) (x264)
What I cannot master is one final piece: If a movie is split across multiple files, I'd like to add "Part_X" to the end of the name. The original name of the file will contain, somewhere in it, words such as "CD1", "Part1", "Part 1", Part_1", "PT_1" and so forth.
I can do a "contains" statement to check for the existence of such phrases - like
But I cannot uncover how to then use the number of the "part".
I suspect there is a clever RegEx that might accomplish it, but when it comes to regular expressions I'm afraid I am at sea.
Does anybody have any suggestions? Or even point me to an existing post that covers this kind of thing?
Eternally grateful
I have a movie naming scheme that I am happy with, borrowed and plagiarized extensively and shamelessly from others' examples.
Code: Select all
{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() })}; norm(n)}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y}){genres != null && (genres.contains('animation') || genres.contains('Animation')) ? ' (Animation)':""}{genre != null && !genres.contains('animation') && !genres.contains('Animation') ? ' ('+{genre}+')':""}{if (any{imdb.certification}{certification} != null) ' ('+any{imdb.certification}{certification}+')'} {'{imdb-'+imdbid+'}'}\{norm(n)}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y}){genres != null && (genres.contains('animation') || genres.contains('Animation')) ? ' (Animation)':""}{genre != null && !genres.contains('animation') && !genres.contains('Animation') ? ' ('+{genre}+')':""}{if (any{imdb.certification}{certification} != null) ' ('+any{imdb.certification}{certification}+')'} {languages.toString().toUpperCase()} ({vs == "" ? "" : vs+" "}{vf.removeIllegalCharacters()}) ({AC} {channels}) ({vc.replaceAll('AVC','h264').replaceAll('HEVC','h265')})
[*]101 Dalmatians II - Patch's London Adventure (2003) (Animation) (G) {imdb-tt0324941}/101 Dalmatians II - Patch's London Adventure (2003) (Animation) (G) [ENG] (BluRay 1080p) (AC3 5.1) (x265)
[*]Escape Plan 2 - Hades (2018) (Action) (R) {imdb-tt6513656}/Escape Plan 2 - Hades (2018) (Action) (R) [ENG] (BluRay 720p) (DTS 5.1) (x264)
What I cannot master is one final piece: If a movie is split across multiple files, I'd like to add "Part_X" to the end of the name. The original name of the file will contain, somewhere in it, words such as "CD1", "Part1", "Part 1", Part_1", "PT_1" and so forth.
I can do a "contains" statement to check for the existence of such phrases - like
Code: Select all
original.toUpperCase().contains('CD')
I suspect there is a clever RegEx that might accomplish it, but when it comes to regular expressions I'm afraid I am at sea.
Does anybody have any suggestions? Or even point me to an existing post that covers this kind of thing?
Eternally grateful
