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:

A screenshot of a Hazel setup window on a desktop computer, titled "TV Show into Plex." It shows conditions and actions for automatically organizing TV show files. The conditions specify that the file name must match a pattern including "Name of the Show," "Season," and "Episode," and have a .mp4 extension. Actions include moving the file to a "TV Shows" folder and sorting it into subfolders named after the show and season.

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.

A screenshot of a Hazel setup window with the "Conditions" section highlighted in red. This section specifies that the automation will trigger if all of the following conditions are met: the file name matches a pattern including "Name of the Show," "Season," and "Episode"; the file extension is .mp4; and the file was not modified in the last 5 minutes.

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.

A screenshot of a Hazel setup window with the "Rules" section highlighted in red. This section details the actions to be taken on files that meet the specified conditions. The rules include moving the file to a folder named "TV Shows" and then sorting it into subfolders based on the "Name of the Show" and the "Season."

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.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.