A Hazel Rule for Getting TV Shows Into Plex
I remember binge-watching Smallville via DVDs that Netflix sent to me in the mail. I would watch four episodes in a row, then mail back the DVD and wait days for the next one to arrive so I could get the next four episodes. When streaming arrived, it was a miracle!
Sadly, a miracle that was too good for this world. Streaming has been on a steady decline for the past several years, while prices seem to increase more frequently than new seasons of hit shows are released. Streaming has turned into cable TV, and the magic is gone.
That is until I found Plex. Check out my original Plex post for more details about setting up a Plex server.
Plex is Awesome
In short, Plex is awesome because you own the media, so you don’t lose access to a great show because of corporate shenanigans.
And You own the hardware, so you also don’t have to deal with random price hikes or password crackdowns. Basically, Plex is what we were promised about streaming in the first place.
Getting TV Shows into Plex Can Be Tedious
That being said, having a Plex server is essentially a hobby.
It requires you to buy some hardware and spend some time taking the physical copies of media you own (e.g., your Blu-ray of T2) and ripping them to files. This can be particularly tedious when you want to have a TV show in Plex (e.g., your DVD box set of The Office).
As you rip your files off of discs, you need to name the file in a specific format so Plex knows which episode is which. Then, you need to organize these individual episodes into a folder for each show and a subfolder for each season.
I certainly recognize that this is a big enough hurdle that most people would rather pay for streaming and deal with the perpetual paper cuts of those services.
Hazel Saves the Day
Fortunately, Hazel is wonderfully suited to make managing a Plex server easier!
I have to admit, after years of running a Plex server, I only recently made this Hazel rule for importing properly named TV episodes into Plex. This uses a few of the very cool (but sometimes opaque) features of Hazel, so I will break it down for you line by line. First, here is what the finished Hazel rule looks like:
Now, let’s dive into the details of this Hazel rule to help you understand what makes this such an effective solution.
Hazel Conditions
Conditions are what Hazel calls the items in the top part of the screenshot; these are the various file attributes that you are telling Hazel to look for. In this example, I am using Name, Extension, and Date Last Modified.
Name Matches
Name Matches is the first condition I am using, and it is the most important.
If you look in the Custom Attributes Field (i.e., the white box to the right of the “matches” dropdown), you can see some blue tokens interspersed with manually entered text. This pattern matches the Plex naming convention for a TV episode:
Parks and Recreation – s02e21 – “94 Meetings”
Since I don’t name any other files on my computer with this format, this rule will only match/apply to episodes of TV shows I want to add to Plex.
Those blue tokens are Custom Text Attributes to identify the Name of the Show and the Season number. Using Custom Text Attributes allows this one rule to apply to any TV show I am trying to get into Plex without having to create new rules or modify this one.
Importantly, by defining these Custom Text Attributes in the Conditions portion of the rule, I can also use them in the Actions portion of the rule (more on this in a moment).
Extension
This condition is really here out of an abundance of caution in case I somehow have a text file or something else that matches the Plex naming format. By checking to make sure that the file is an mp4, this condition prevents this Hazel rule from moving a non-video file into my Plex library.
Date Last Modified
This condition gives me a five-minute buffer to double-check my work naming the file. I make plenty of mistakes while converting the ambiguously named files that come off of a DVD (e.g., title_01.mkv) into the proper Plex naming convention, so having a couple of minutes to make sure I got it right saves a lot of headaches.
Hazel Actions
The bottom portion of the Hazel rule is the ordered list of actions that Hazel will perform on any file that matches all of the conditions we defined above.
Move
This action will move the file to the root level of the TV Show folder of my Plex library on my NAS. However, if it is left there, it will remain invisible to Plex and might as well not exist.
Sort into subfolder #1
This first Sort into subfolder action uses the “Name of the Show” Custom Text Attribute we defined earlier. This rule will look for a folder inside of my TV Shows folder that matches the “Name of the Show.”
If Hazel finds an existing folder, it will move this episode into the correct folder for that show.
If Hazel can’t find an existing folder, it will create a new folder for the show and move this episode inside of the newly created folder for the show.
Sort into subfolder #2
But Plex will still not be happy with an episode inside of the folder for a TV show. Plex wants each episode to be inside a folder for each season of the show.
This second Sort into subfolder rule is now looking inside the folder for the show for season folders. Hazel will use the Custom Text Attribute we used to identify the Season, and it will do the same thing as before: either move the episode to the correct existing folder or create a new one.
Conclusion
I am a little embarrassed that it took so long to merge my loves of Plex and Hazel, but I am so happy to have a universally applicable Hazel rule for importing TV shows into Plex.
Now, I can name a file and have a new episode in Plex in just a few minutes without the tedium of creating a folder on a network drive and dealing with the occasional laggy interactions in Finder.
Let me know in the comments if you have any Hazel rules that you are proud of, even if it took you longer to create than you wish it had.
If you have a plex server just install the *arr stack next to it instead of this. Granted most people use it to illegally download stuff but, if you’re not it’s still very helpful in managing the media and renaming thing’s automatically as well as putting it in the right folder and maintaining the folder structure. Yes it’s a bit more difficult to install but so much more powerful and once it’s installed it’s done and you pretty much just throw media at it and it takes care of it.
Thanks Chris! I have been aware of the world of Plex plugins and accessory apps, but I have never really dug into it before. This might be the nudge I need to explore it.
This Hazel rule is handy for me because Hazel is already a major part of my workflow, and adding this rule was a simple enhancement I could make with the tools I already had. However, it certainly sounds less powerful than the tool you suggested.
Thanks again!