First, some background information...
I use P: as my Plex drive, meaning it contains the database, etc. It also have various junction links to folders on other drives, such as P:\_01 linking to the "Media" folder on the first drive containing my media collection. P:\_02 does the same thing but on the second drive, etc. I also have a P:\dev folder, where the same numbers (P:\dev\01) link to the root of the drive.
The benefits to doing this is that on Plex, I just add in folders P:\_01\TV, P:\_02\TV, etc. No need to assign drive letters, unless desired. Also, no need to remember drive letters, and adding another drive keeps scripting simple as well. Same with having the root of each drive linked in a \dev\ folder, in case it's needed.
Code: Select all
P:/_{any{folder.path.match(/.:\\_((?:dev)?\d\d(?:\\|$))/)}{"03"}}/TV/
For anyone wondering, I store newly creature media files in a different structure, so that I can verify that it works without issues in Plex, before fully integrating it. Thus the \dev\ use. Same structure, just a different root folder name. Also, the files don't get all the same fancy naming done to them, so if I have a few different copies, I can more easily identify and remove the culprit among a smaller group of files. After I'm sure everything is fine, I can FileBot them to their final homes.
Code: Select all
{any{concat(readLines('P:/series.txt').find{ it =~ /^${info.id} / }.after(/^\d+\s+/)).before(/[:#\t\/*\\]/)}{"${ny.colon(' - ').validateFileName()} (${y})"}}
71470 Star Trek TNG
72073 Star Trek DS9
You can add a tab and then a comment after the name if you want to add any comments for personal use (will be ignored by filebot).
An example of the above being used:
Star Trek DS9/Season xx/
Star Trek TNG/Season xx/
If not used, then the original name will be used with the year appended to it:
Star Trek Deep Space Nine (1993)/Season xx
Star Trek The Next Generation (1987)/Season xx
This can also be modified to mix two different shows into one main folder, though I'm not sure why anyone would want to do that.
Code: Select all
{"/Season ${episode.special || episode.special == 0 ? '00':s.pad(2)}/${ny.colon(' - ').validateFileName()}"} ({y}) - {s00e00.lower()}
After that the name of the show, the year the show started, and the season/episode numbers. The little extra work you see taking place is convert any colon's to a dash surrounded by spaces, and to validate the name for use. You'll also notice I'm using {ny} instead of {n}, which adds the year to the end of the name. I like to have a year added after the show's name for consistency and reference. Maybe I have OCD, but seeing some titles with a year and others without, it bugs me. (Some titles have the year attached even without the 'y' being used.)
Code: Select all
{if (n != "Tom and Jerry") airdate.format(' - yyyy-MM-dd') else airdate.format(' - (MMM dd)')}
Code: Select all
{" - ${t.replacePart(' (Part $1)').colon(' - ').replaceAll(/[*]/,'-').validateFileName()}"}{".[${crc32}]"}
Other useful expressions...
Code: Select all
{ny.colon(' - ').validateFileName()} - {s00e00.lower()}{" - "+fn.after(s00e00).after(/\.| (- )?/)}
For movies...
Code: Select all
{any{"_ COLLECTIONS _/".concat(any{MC:{readLines('P:/collections.txt').find{ it =~ imdbid }.after(':').before(/[:#\t*\/\\]/)}}{collection.colon(" - ").validateFileName()})+"/${y} - ${n.colon(" - ").validateFileName()}"}}
If you look closely, you'll see a bonus here, which allows you to create custom (or override existing) movie collections. Some movies are already associated with certain collections, but you may want to rename it or alter which collection a particular movie is saved to. With some work, this could also be made to exclude certain movies from being in a collection (file structure wise, not Plex wise). The format of the "collections.txt" file is rather simple:
tt0055928;tt0057076;tt0058150;tt0059800;tt0062512;:James Bond Collection
Mind you, the ;'s are really necessary, and could be replaced with spaces, commas, periods, middle fingers, etc, just not colons. The colon tells the expression where the name of the collection starts. For anyone wondering if there's a change of an false hit despite having proper IMDb ID's in the file, the ID's are all the same length, so if it finds a match, then it's the correct match (assuming you put the correct ID's in there). I have a BluRay set of James Bond movies, and using this allows me to ensure that files are always in a collection, even if an online database doesn't have it properly added. If I wanted to, I could rename it to "007 Collection" or "007 James Bond" or something else. (There are a few more lines in my file for the JB collection, the line shown is just an example.)
Questions, comments, jaws on floor from confusion?