Creating a Watch Folder for Compressor 2

Many video compression programs like Sorenson Squeeze let you create watch folders to automatically launch compression jobs. The idea behind it is easy: drop a video into the assigned watch folder and the program immediately starts converting the item based on a pre-assigned template.

Sadly for users of Final Cut Studio’s Compressor 2, the ability to set up watch folders is not built in. But with an AppleScript-based Folder Action and a custom Compressor droplet you can quickly set up a comparable automation system.

The first step in setting up this automated workflow is to create a Compressor droplet. To do this, open Compressor 2’s Presets window. Click the Create New Settings Group button (the button above the number 1 in the screenshot below). It will create a folder in the Custom settings. Name it Droplet. Now pick the compression settings you want from the Apple presets, or create your own custom settings, and drag them to the Droplet folder. In my example, I want my droplet to execute five different compression types.

Compressor 2 presets

Click on the Create Droplet button (the one above the number 2 in the screenshot above) and save the droplet to your desktop.

Now that you have a Compressor droplet, it’s time to create the watch folder. Choose a location, create the watch folder and name it To Compress.

Now open your Script Editor (in the folder inside the Applications/AppleScript folder) and copy these lines of code into the editor. Change the words “YourUserName” in the script below to your own account username.

on adding folder items to thisFolder after receiving theItems

  -- this is the standard intro for a folder action

  repeat with f in theItems

    -- wait for the item to be all there

    set Was to 0

    set isNow to 1

    repeat while isNow ≠ Was

      -- the basic idea is that the script loops until the file size is the same for more than 30 seconds. That means the file has finished copying.

      set Was to size of (info for f)

      -- this section is getting the file size of the video

      delay 30

      set isNow to size of (info for f)

      -- this section is sampling the file size 30 seconds later

  end repeat

  tell application "Finder"

      open theItems using application file "Droplet.app" of folder "Desktop" of folder "YourUserName" of folder "Users" of startup disk

  end tell

  end repeat -- get next item f in thisFolder

end adding folder items to

The repeat delay is 30 seconds in this example. After some trial and error, I made the delay this long so that I could use the script for live video captures in Final Cut Pro (to account for tape preroll and cueing). To use this script with Final Cut, just make the project’s capture scratch subfolder (not Final Cut Pro’s main capture scratch folder) the watch folder.

Save the AppleScript as “SendVideoToDroplet,” with the file format script and put it in your /Library/Scripts/Folder Action Scripts/ folder.

Now the bulk of the work is done. We just need to attach the AppleScript Action to the watch folder. Control-click your watch folder. If you haven’t enabled Folder Actions, enable it now from the pop-up menu. Once Folder Actions are enabled you can attach the script you created. Control-click the folder again and choose Attach Folder Action from the menu.

Save droplet

Now pick the SendVideoToDroplet script from your /Library/Scripts/Folder Action Scripts/ folder.

Your watch folder is ready. Test the watch folder by dragging a video clip to the “To Compress” watch folder. Now, remember the Applescript waits 30 seconds between checking the file size, so you will have slightly more than a 30 second delay for the process to start.

The first time you run a Compressor Droplet, it will ask you where you want to save the finished files and how you want them named. Set these options as you wish and make sure to click off Show at Launch.

Once the “Show at Launch” is disabled, all subsequent jobs you sent through your newly created watch folder will proceed immediately.

That’s it! If you’re looking for more helpful hints on AppleScript, the MacScripter Web site is invaluable.

Subscribe to the Apple @ Work Newsletter

Comments