• Oh Hazel, you're so great I had to write about you 3 times. In Part 1, we looked at automatically handling incoming files, and encoding them into iTunes friendly format using Hazel. In the glorious Part 2 of this series of articles, we looked at automatically renaming files using funky fresh matching patterns, so that all your media is named beautifully. Here's where Part 2 ended:

    Pt2FinalProduct.png


    So your files have been automatically encoded into h.264, and dropped into a sorting folder. From there they have been automatically renamed into a standard filename. Sweet! So what's next?

    Step 4: Tag files with metadata & add artwork


    This step draws on the great work done by true Mac media genius who goes by mac.jedi over at the Macrumors forums. He has a wonderful How-to on Automating DVD backup (How-To: Automating DVD & Blu-Ray (Backup, Encoding & Tagging) for Mac OS X 10.6), but what he has also kindly written are a series of scripts for tagging media automatically with metadata.

    I won't rip off his work by directly hotlinking to his packaged scripts, but if you go to his thread, you'll see the following:

    How-To_ Automating DVD & Blu-Ray (Backup, Encoding & Tagging) for Mac OS X 10.6 - Mac Forums-1.png

    Grab the .dmg file - it's about 15.4mb in total. This will be the base by which we can start automatically tagging these files with metadata.

    Batch Rip Actions for Automator.png

    Run the included installer. This installer with add a bunch of new workflow files and Services that we can start to tap into.

    Install Batch Rip Actions for Automator - TV & Movie Tags.png

    These are the two key Services that we can use. Now, the important part to know about these is that they are based on filename. If you have a standard filename (like we do!), then these two scripts can successfully search for your files on both thetvdb.com, or themoviedb.org, depending on whether they are movies or TV shows. If they can find them there, then they will automatically scrape all the metadata details of the show/movie, and apply it to your file!

    For those keeping score, you're probably thinking, "Ah-hah! This is why Part 2 is so gosh-darned important!"

    Well played, dear reader. Oh, I feel like I know you so well now, after all we've gone through. Could we be friends, in different circumstances? I'd like to think so.

    I command you, rise and be tagged


    So let's revisit our Hazel rules:

    Hazel.png

    The highlighted rule down the bottom is going to be doing the heavy lifting for us. Let's take a look.

    Rule: Attempt TV Tag for Downloads


    About to be sorted - TV rule.png

    Let's break down this rule bit by bit. So if a file...

    • has a name that matches the naming scheme we have set [Show] - S[Season]E[Episode]

    • has an extension of .m4v

    • has a musical genre of 'blank' (this is one of the most reliable ways to tell if a file has been tagged before or not)

    • does not have the Spotlight comment 'Tagging Complete' (again, checking to make sure the rule has not tried tagging this file before)

    • does not have the colour label of Blue


    ...then it is ready to be tagged! But wait, those beautiful Services you installed before, where did they go? They all live in your User Library/Services folder, located here:

    Services.png

    We do need to make one customisation to the Batch Rip • Add TV Tags.workflow file in here, so double-click it and it will open in Automator.

    Customising the TV Tags script

    We want to check the box that says, "Replace original file". This means that the old non-tagged file will be overwritten by the workflow, not just duplicated.

    Batch Rip • Add TV Tags.workflow-1.png

    Save this change to the workflow, and close Automator.

    This is a sidenote, but I will quickly mention that because these Automator workflows are all Services, you can actually trigger them at any time for any file, just by right clicking on it.

    Right click services.png

    Services in action - isn't it cool?

    OK, so continue to set up your rule so that if your file meets your exacting criteria it will trigger the workflow in your Services folder called Batch Rip • Add TV Tags.workflow.

    Run automator .png

    You also want to add that 2nd 'Add comment' rule to replace the pre-existing Spotlight comment. That just lets you know which files are done with tagging, and which aren't.

    Now, if all goes well, you should see your sample file automatically trigger the rule you just made. It will look like this while it is working:

    tagging_file_in_progress.png

    Oooh, pretty. That means that the script was successful in finding your show on thetvdb.org, and is now writing a 2nd temporary copy with all the metadata tags embedded into it. Once it is done, it will delete the original untagged copy. An easy way to see the difference between a tagged copy and an untagged copy is the icon used in the Finder. Here's a heads-up comparison:

    taggedvsuntagged.png

    The finder is smart enough to recognise the tagged file has album artwork now, and uses that for the file icon instead of the random video screengrab of the 2nd.

    So, at the end of all this, you should now have a freshly-minted copy of your video file with all that sexy metadata included:

    your file has now been tagged sucessfully, and is ready to go

    Rule: Mark as Tagged


    The 'mark as tagged' rule in detail

    This rule ensures that any file you have successfully tagged ends up with the blue colour label. Because your previous rule actually ends up creating a brand new copy of the file, you need to now examine that new copy and apply the label.

    So if a file...

    • has a Spotlight comment of 'Tagging Complete'

    • has a filename without the word '-temp-' in it. The dashes are necessary because otherwise it might pick up a show like oh, say Temptation Island, or The Knights Templar. As an avid Temptation Island fan, I found this out right away. Just kidding, nobody watches that show.


    Actually, I'm pretty sure if you simultaneously like Temptation Island and own a Mac, Scott Forstall is obligated to break into your house and beat you to death with a iPod Hi-fi.

    4309544281_423f4ed002_z.jpeg

    He'll do it, the dude has crazy eyes. Wait, where were we? Oh yeah...

    If your file...

    • does not have the colour label of blue

    • has a musical genre that is not blank


    ...then it's definitely been tagged by your process. So we will set its colour label to blue. Now our sorting rule (up next) will know what can be sorted.

    set the colour label of the file to blue

    Step 5: Sort to folders & Add to iTunes library


    Home stretch! So now we've validated that our file has been tagged, our file should look like this:

    our file has been colour labelled, and is ready to sort into folders

    The final step in our process is to sort it to a logical series of folders, and add it to iTunes. Back in Part 1, I talked about sorting into a folder hierarchy of show & season. It looked like this:

    Hazel Tutorial Pt 1 - Final Product .png

    How do we accomplish this automatically? Can you do it, Hazel? Oh hell yes you can. Incoming rule!

    Rule: Sort to TV Show folder

    Rule: Sort to TV Show folder


    Let's take a look at this bad boy in detail:

    Rule in detail: Sort to TV Show folder

    So if a file...

    • has a name that matches the [Show] - S[Season]E[Episode] custom token naming scheme (for more info on this, see Part 2 of this series). This part is really important, because Hazel needs to know the seperate components of this filename again (like Show, Season, Episode), so we can use them below for sorting.

    • has a colour label of blue


    ...then do the following:

    • Move the file to your TV Shows folder

    • Sort the file into a subfolder


    This is where the magic of custom tokens help us out yet again. We can firstly define that the file is sorted into a Show subfolder. Secondly, we can use the little arrow token, to further sort this file into a Season subfolder as well.

    iconseperatesubfolders.png

    Again, Hazel is cropping out my full pattern here, but it looks like this. The stuff in square brackets are all tokens, which you can drag and drop into the pattern area.

    [Show][>]Season [Season]

    So if your filename is:

    Arrested Development - S01E01.m4v

    The custom tokens will recognise:

    • The show name is Arrested Development

    • The Season is 01


    One change we need to make to our custom token is to to have Hazel recognise only 1 digit of this Season number. Otherwise, Hazel will create a folder of Season 01, not Season 1. Picky I know, but hey, we've come this far, right? Let's blow this freakin' tutorial right out and go the whole damn hog.

    Click on the arrow drop-down on the token, and you get the option to modify it:

    changetoonedigit.png

    Hell yeah boyee. This will now sort this file into a folder hierarchy of:

    TV Shows > Arrested Development > Season 1

    Even better, if the subfolders don't exist, then they will be created by Hazel.

    Before I dig into importing into iTunes, I have to warn you about turning off a setting in iTunes. Head to iTunes > Preferences > Advanced and you'll see this:

    itunescopyfiles.png

    If you don't uncheck the box beside Copy files to iTunes Media folder when adding to library, then iTunes will take it upon itself to sort your files. In principle this would be OK, but the naming scheme iTunes uses is woeful, and it means files are very difficult to identify later. So switch it off. This has other implications, though, so be mindful of your current iTunes setup, and how you currently add music to iTunes. Besides, if you followed my 'Automatically Add to iTunes' trick in Part 1, it's already taken care of.

    Now you've done that, the import component of this rule is to import into iTunes is really simple.

    importintoitunes.png

    You have the option to also add the file to a playlist when you import it. I highly recommend this because you can just check the playlist to confirm that stuff is being successfully imported.

    Finally, just to be neat, here's an action that removes the colour label we used.

    removes the existing colour label

    Now the file we've been playing with looks like this:

    finalproductpt3.png

    It's been completely automatically encoded, renamed, tagged, sorted and imported. It looks like this in iTunes:

    finalproductitunes.png

    Isn't life grand?

    Summing Up


    This set of steps will let you not only convert new material, but also pre-existing stuff. Simply drop files into your Complete folder and let Hazel do all the work for you. As an added bonus, this kind of set up also plays nice with XBMC-based media centre setups, like Plex and Boxee, because the folder names, folder hierarchy and file-naming scheme we have used are totally compatible with how they find metadata -- mainly through file-naming consistency.

    If you'd like to ask me any questions about this setup, my Twitter account is @jamescroft. Hit me up there. Thanks for reading!
  • New Forum Posts

    LCGuy

    I second Byrd and bartron - max out the RAM, stick in a fast, big HDD, and do a fresh install of Snow Leopard, and you'll be very happy with that machine.

    Shall I resurrect him? (iMac mid 2007)

    LCGuy Today, 11:09 PM Go to last post
    bennyling

    If you use Chrome, check out the extension called Page Monitor: https://chrome.google.com/webstore/d...enbfclihhmmfcd

    Get notified when a webpage changes?

    bennyling Today, 11:00 PM Go to last post
    bartron

    I'm with Byrd.

    Max out the RAM and stick with Snow Leopard and you'll have a pretty decent machine to see you though. Hard drive replacements

    Shall I resurrect him? (iMac mid 2007)

    bartron Today, 10:51 PM Go to last post
    decryption

    Nah, I haven't. A bit pricey just for stuffing around, but I know the developers (just in passing, nice guys on Twitter) and have heard nothing but good

    iPad for offroad 4x4 mapping

    decryption Today, 10:37 PM Go to last post
    Byrd

    I'd max the RAM (4Gb would do), and pick up a fast 1TB+ 7200RPM hard disk for it; not worth spending a huge deal on an SSD when it costs more than the

    Shall I resurrect him? (iMac mid 2007)

    Byrd Today, 09:38 PM Go to last post
    soulman

    That looks cool. Have you used this Anthony?

    iPad for offroad 4x4 mapping

    soulman Today, 09:10 PM Go to last post
    fulltimecasual

    Bummer. Well, if mine starts cracking, i'll let this thread know.

    New iPad Cases - What are ya buying?

    fulltimecasual Today, 08:17 PM Go to last post
    ETHERSPIN

    Hi guys,pinched for pennies (off work with illness) but my formerly lovely iMac is not coping with life at all!

    its a mid 2007 20 or 21 inch

    Shall I resurrect him? (iMac mid 2007)

    ETHERSPIN Today, 07:25 PM Go to last post
    soulman

    Hey Scott,

    I understand now and, yes, that makes sense if you can make it work. There are some good CIS systems apparently, but I can't

    Printing images

    soulman Today, 06:27 PM Go to last post
    cactus68

    Byrd hi,

    have tried all that
    I have iStat
    CPU fan 3600rpm 34'C
    Hard Drive 1350rpm 46'C
    Optical Drive 701rpm

    HDrive 4 a iMac late 2008

    cactus68 Today, 06:21 PM Go to last post