Syncing Folders

Hazel’s Sync action copies items from the monitored folder to another folder—but unlike the Copy action, Sync copies only those items that have been added since the last time the rule ran. So you can think of it as being like a smarter or more efficient Copy.

Syncing items in Hazel differs from how some utilities use the word “sync.” You’ll get better results with the Sync action if you understand its limitations. Specifically:

- One-way syncing only: Syncing in Hazel is one-way; files changed in the destination folder are not copied back to the monitored folder. Although you could in theory create mutual syncing rules for both source and destination folders, we recommend against doing this. Hazel was not designed for two-way sync, and it does not have the capability to handle conflicts and other complex situations the way a dedicated sync app such as ChronoSync can, nor will its syncing performance be anywhere close to that of a dedicated app.

- Deletions are not synced (by default): If a rule syncs files in the monitored folder with another folder, and then you delete an already-synced file from the monitored folder, that file will not disappear from the destination folder. That’s because Hazel’s rules normally operate only on files and folders that match your conditions, and the absence of a file that previously existed in the monitored folder is not something a condition can match.

  You can work around this limitation by using a rule that looks for any change in a subfolder of the monitored folder. This works because, from Hazel’s point of view, the list of files in a folder is a property of that folder. Once the subfolder matches your condition(s) and syncs, its entire list of files is processed. And, as a result, any files deleted from the source will also disappear from the destination. However, a side-effect of this approach (which may or may not be to your liking) is that the destination folder must contain a copy of the entire subfolder being synced—not just its contents—as described below.

Sync a Subfolder (including Deletions)

Here’s how you can set up Hazel to sync an entire subfolder of a monitored folder, including deletions. To be clear, if the monitored folder is “Monitored Folder” in the example below, the folder you want to sync—inside the monitored folder—is called “Synced Folder” and the destination is “Destination Folder,” the result after syncing will look like this:

That is, the contents of “Synced Folder” don’t sync directly to the top level of “Destination Folder,” but rather to subfolder “Synced Folder” within “Destination Folder.” Anything deleted from “Synced Folder” in the monitored folder is deleted from the “Synced Folder” at the destination. Syncing is only one-way; changes in the “Synced Folder” subfolder of “Destination Folder” do not sync back to “Synced Folder” in the “Monitored Folder.”

The rule that performs this sort of sync looks like this:

You can create this rule manually (be sure to read Using Nested Conditions for help with the last four lines in the “conditions” section), or, if you prefer, you can download this rule using the following link: sync.hazelrules . After you’ve downloaded the rule, open Hazel, select the folder you want to monitor (that is, the folder that contains the folder you want to sync), and drag the rule into its “Rules” list. Then edit the rule and replace the name of the “Synced Folder” and the “Destination Folder” with the folders you want to sync.

This rule looks for a folder inside the monitored folder with the name you specify. When Hazel detects changes in that folder—or in any of the subfiles or subfolders within it—the “Sync” rule runs, copying the contents of the synced folder to the destination folder.

Note that the conditions shown here merely tell Hazel when to sync (in this case, whenever the subfolder is modified). If you prefer, you can use entirely different conditions (such as Current Time is 12:00 AM any day) to specify a different schedule or frequency. Regardless of the conditions, the “Sync” action itself behaves the same way.

Tip: The conditions in this example rule are applicable to many actions, not just syncing. You can use the same conditions to trigger any action every time something is modified.

Because this rule runs every time “Synced Folder” or anything inside it changes, it can bog down your Mac a bit if that folder contains a large number of items. If you want to limit how often it runs, you can do so by adding “Date Last Matched is not in the last 10 minutes” (or however long you want the interval between runs to be) to the top of the conditions list.

SEE ALSO

Processing Subfolders

Using Nested Conditions

Action Reference

Copying Folder Structure

Specifying Upload Options