• 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

    torana355

    Upgraded to Ultimate this week

    Am I crazy to consider BigPond Cable?

    torana355 Today, 01:19 PM Go to last post
    Mongrel

    Hmm... I guess I am on my own.

    Finder won't search though a Samba share

    Mongrel Today, 01:12 PM Go to last post
    fan

    Try Sony 5600 receiver. I design million dollar Broadcast systems and I was amazed how good this Rx is. It has auto phase calibration and also IP switch.

    A/V receiver suggestions/advice

    fan Today, 01:10 PM Go to last post
    torana355

    Nice speaker selection, you have the SE 3 floorstanders?

    Honestly sound is completely subjective, what you need to do is test out different

    A/V receiver suggestions/advice

    torana355 Today, 12:53 PM Go to last post
    vivid2

    And I thought the Q was a visual horror. This thing (as Kyte noted) has been hit hard with the ugly stick and has no viewfinder. Bulkier than some worthy

    New Pentax Mirrorless - K-01 - Announced.

    vivid2 Today, 11:35 AM Go to last post
    Chundermuffin

    I'd be calling the iAmbulance for that one.

    Fritzed iPad Screen :(

    Chundermuffin Today, 11:06 AM Go to last post
    digitalmvp

    I have solved the mystery...press and hold the touchpad. You will hear click like windows mouse. Viola....

    Magic Trackpad refuses to allow me to select my profile at Login on MBP

    digitalmvp Today, 11:05 AM Go to last post
    b00

    Hey Guys,

    Just wondering if there is anything i can do to fix the screen on my iPad before i take it to an Apple Store.
    Every

    Fritzed iPad Screen :(

    b00 Today, 10:20 AM Go to last post
    doofus

    Its a quirky looking design that seems somewhat compromised but I am sure the image quality will be very good.

    New Pentax Mirrorless - K-01 - Announced.

    doofus Today, 07:45 AM Go to last post
    emerson

    Thanks Torana, i'll check this one out too.



    I've heard some great things about the sound of Anthem amps but heard they

    A/V receiver suggestions/advice

    emerson Yesterday, 09:55 PM Go to last post
    jdm1503

    I am having problems with my new Mac Mini Lion Server and wish to reset the server back to the factory defaults and start all over again. Does anyone

    Reset Lion Server back to factory defaults

    jdm1503 Yesterday, 09:48 PM Go to last post
    ravage221

    Not too bad speeds for the 40/2

    Geelong ISPs/Phone Cos

    ravage221 Yesterday, 09:31 PM Go to last post
    moto51

    Am I right in saying the device you are seeking recommendations for is to be used on lunch breaks, not at uni because you have your Pro?

    Need a portable laptop/netbook

    moto51 Yesterday, 07:10 PM Go to last post
    maclab

    Because the battery issue is still a major problem.....better for some but not for all..

    iOS 5.1 beta3

    maclab Yesterday, 06:46 PM Go to last post