Automate uTorrent to handbrake workflow

HI there,
I want to do the following:
After a BitTorrent download complete uTorrent automatically moves it to a folder named COMPLETED.

From here I want to move any mp4 encoded movie files to the “Automatically Add to iTunes” Folder, as well as any mp3 (or other music) files.

I want to transcode all other movie files (e.g. AVI, MKV) to MP4, the apple TV3 format. I found an Applescript to do this last part with handbrake CLI. Not sure if it works though. (see below)

Once the files are encoded in the right format I want to move them to the “Automatically Add to iTunes” Folder too.

Now I want to delete any left overs (empty folders, txt files, subtitle files etc.).

Any hints on how to get this automated through KM? Below is the apple script with link to the hazel forum where I found it, that should take care of the handbrake part, but the other (KM) parts I am still unclear how to best solve them. Any hints are welcome

       tell application "Finder"
             --Set to red label to indicate processing
             set label index of theFile to 2
             --Assemble original and new file paths
             set origFilepath to quoted form of POSIX path of (theFile as alias)
             set newFilepath to (characters 1 thru -5 of origFilepath as string) & "m4v'"
             --Start the conversion
             set shellCommand to "nice /Applications/HandBrakeCLI -i " & origFilepath & " -o " & newFilepath & " --preset=\"AppleTV 3\" ;"
             do shell script shellCommand
             --Set the label to orange
             set label index of theFile to 3
          end try
       end tell
       tell application "Finder"
          set movieName to name of item theFile
       end tell

Well, you can start with Watch Folders. I recently viewed this tutorial:, which can probably get you started.

Let us know what help you need from there.

That is a really good video, and a great demonstration of the For Each action, the If Then Else action and the Periodic trigger, but note that it is using an older version of Keyboard Maestro.

If you are using version 7, you can use the Folder trigger to watch a folder, and then simply move or otherwise operate on the %TriggerValue% file.

The watched folder trigger isn't too hard. But next how do I get all files out of the subfolders into the folder I am watching?
Also, I can't seem to figure out how I can move files based on their extension (I want to move all mp4 and m4v files to iTunes import folder right away before moving on to the next step).

here is my skeleton of a workflow...Torrents Automated 1.kmmacros (5.7 KB)

FWIW, I’d also really love an answer to David_Landes’s question here.

  • Trigger on folder change
  • Move File %trioggerValue% to ~/Downloads

Peter - What will %TriggerValue% contain if a subfolder with contents is added, not just a file?

Fortunately, uTorrent moves the folder from its “downloading” folder to its “completed” folder, so the chances of catching a partial file ore minimized.

If a folder is added to the folder you are watching, then %TriggerValue% will have the path of the folder.

1 Like