Automaton Icon

Rules


Rule Basics

Complex Conditions

You can make a condition as complex as you like with ANY and ALL conditions. Normally when you press the + button, it will add a condition to the current ANY/ALL conditions.

However, if you hold down the option key, the "+" will change to a "..." and allow you add complex sub-rules.


Complex Actions

You can use the same technique with actions to specify what happens if a step fails. For example, you could take failover actions, or use a Growl message if a particular action fails. The two options you have are to execute a list of steps until one of them returns failure, or until one of them returns success. You can nest the logic as deep as you like by using the same trick of holding down the Option key.

Creating Rules

To create a rule:

  1. In the AutoFiler window, click the plus (+) button under the Rules list to create a new rule. This will display the rule interface.
    • You can also copy an existing rule by selecting the Duplicate option in the action menu [].
  2. Enter a description so that you can identify the rule.
  3. Select Any, All or None to indicate whether you want any, all, or none of the conditions to match before executing the actions.
  4. Create conditions by selecting the attributes and values. The options will change according to the attribute selected.
    • You add more conditions clicking on the plus ["+"] button on the right of the condition.
    • You add complex logic conditions by holding down the Option key and clicking on the elipses ["..."] button on the right of the condition.
    • You can remove conditions by clicking on the minus ["-"] button on the right of the condition.
  5. Create actions. As with creating conditions, the plus, elipses and minus buttons add actions, add complex logic and remove actions, respectively.
  6. When finished, click OK to save your changes or Cancel to discard changes.

Applying rules to sub-folders

You will probably find that most uses of AutoFiler only require you looking at files that are directly in the folders you specify. But there may be some cases where you want to examine subfolders as well.

This can be achieved with the on subfolder contents action. If the folder matches the conditions then it will run the rules from the specified Rule Set on the files in that folder.

This process decends down step by step from the top level folder, provided that the conditions are met at every level.

In deciding what method to use to scan subfolders, you should take into account that scanning subfolders can be processor intensive. Here are some guidelines to help you:

Mutually Exclusive Rules (Finish Processing)

The Finish Processing check box on the rule sheet can be used to make mutually exclusive rules.

If a rule has the Finish Processing box checked, then no further rules will be considered after this rule, if the rule's conditions are true.

You can also use this action to ignore a file completely, or by having a list of rules, each with the checkbox set, it makes a mutually exclusive set of rules.

Note that this only finishes the currently executing collection of rules. If you had for example, two Rule Sets applicable to the one folder, this would only finish the rules from the current Rule Set.

Creating rule collections

If there are collections of rules you need to run in different places, you can create a Rule Set to act as a kind of subroutine. Just create a Rule Set (there is no need to add associated folders). Then you can execute this set of rules from other Rule Sets with the run other rules action.

Copy and Move with Pattern

Copy and move with pattern allow you to move or copy files with a pattern matching field. All the tokens have the same meaning as found in the conditions references.

There are also tokens for accessing the path relative to the monitored folder. Let's say we have a folder layout like this:

Assume that "B Folder" is the folder we are monitoring, and assume that we have a separate rule for descending into sub folders:

If processing "A File", then relative path will expand to simply A File, since it is at the top level. relative folder will expand to nothing as it is the top level.

If processing "B File", then relative path will expand to C Folder ▸ D Folder ▸ B File and relative folder will expand to C Folder ▸ D Folder

You can use this feature to copy or move files while keeping the same folder hierarchy:

In the above example the Duplicate folder will be one level up relative to the monitored folder. So the duplicate will be in Macintosh HD ▸ A Folder ▸ Duplicate

Reschedule

Let's say you have the case of a program that slowly creates files. Examples of this are download programs, and programs like Handbrake which slowly encode files. Well behaved examples of these programs usually do something like add a .partial file extension of their files until they are finished. This allows programs like AutoFiler to know when they are complete. If a file was called say MyMovie.mov.partial, it wouldn't be recognised as a movie until it was done. Programs like Speed Download do this.

But what if you are not dealing with a well-behaved program? AutoFiler rules will do things to your incomplete files, resulting in problems. One thing you can do, is I would encourage you to hound the developers of these programs mercilessly until they fix them. But what about while you wait?

One thing you can do is to make it a condition of your rule not to act on a file if it has changed recently. If the last changed date is in the last 10 minutes, chances are it may still be incomplete:

The trouble is, AutoFiler usually runs in two circumstances: when something changes, and also the periodic timer:

In this case we want the rule to run when something has not changed. The periodic timer would eventually run the rule, but at least by default, it only runs every 6 hours. You could set it to run more often, but it seems a shame to waste CPU cycles checking too often, and maybe you don't want to wait 6 hours.

What we can do to solve this is to run a Reschedule rule. What this does is that if a file is found to match the rule, all the rules are guaranteed to be rechecked again after the given time period. In this example, if we find a movie file that has changed in the last 10 minutes, we are going to be guaranteed that all the rules will be run on this folder again in 5 minutes. This reschedule runs after the file stops changing, every 5 minutes until it finds the file to be at least 10 minutes old.

One thing to make sure of, is that the Always Recheck Rules box is checked. You want the rescheduling to keep happening until the file is complete. Without checking this box it would only have one attempt at rescheduling before giving up. If your encoding took more than 10 minutes, your rules wouldn't run.

Why did we choose 5 minutes, and not say 10 minutes to reschedule? Actually, it doesn't matter that much, either way will work. If we chose 10 minutes reschedule time, it could in unusual circumstances take up to 20 minutes for the rule to run, in the case that a second movie file in the same folder kept changing for 9.9 minutes after the first movie finished, since only one reschedule per folder is active at once. By setting the number at 5 minutes we guarantee the rule to run within 15 minutes of the file finishing. We could set the reschedule time to be 1 minute, in which case its a trade off between efficiency and timeliness.

One thing we should ensure is that the reschedule rule runs before your other rules:

This avoids the very unlucky scenario that when the rescheduled rules run, the Movie rule is checked just before the 10 minute cut off and doesn't run, and the Reschedule rule is checked just after the 10 minute cut off and doesn't reschedule.

This is still not completely ideal, since programs like Handbrake allow you to pause encodings, and AutoFiler can't detect that the reason the file has stopped changing is not because it is complete, but because you paused it. As I said, keep hounding those developers.

See also

Conditions Reference
Actions Reference