Using Match Patterns in Conditions

Sometimes you may need a rule to check for a condition that matches a  pattern  as opposed to one that simply matches a fixed attribute (for example, “match any file with a three-digit number in its name,” as opposed to “match any file with the number 372 in its name”). Hazel offers an extensive pattern-building interface for just such situations. (You can also use patterns in actions, but the process is a bit different; see  Using Patterns in Actions .)

For the following attributes, you can create patterns by choosing “matches” or “does not match” (or “match”/“do not match,” or “contain match”/“do not contain match,” depending on the context) from the second pop-up menu of the condition:

For example, you might create a pattern that means “Name matches any word, followed by a hyphen, followed by any number.”

When you click in the field to edit a “match” or “does not match” pattern, a popover like this one appears:


Fill in the field at the top of this popover with the pattern you want. You can use a combination of plain text you type yourself (to include static elements as part of your pattern) and  tokens —blue bubbles representing any of numerous variables. To add a token to your pattern from the list below, either click it (once) or drag it to the desired position in the pattern.

For instance, in the image above, the pattern specifies a word (any sequence of letters) followed by a hyphen, followed by a number (one or more digits). Using that pattern, the name  blah-123  matches, but not  123-blah  (which doesn’t start with letters),  blah123  (no hyphen after the word) or  blah-blah  (no number at the end).

Here’s what each token matches:

When you’re finished building your pattern, click Done to close the popover and continue creating or editing your rule.


Match Pattern Rules and Tips

Although most patterns are self-explanatory, you should be aware of a few special considerations:

SEE ALSO

Editing Date Patterns

Using Custom Attributes

Using Patterns in Actions