Custom Date Attributes

in addition to  custom text tokens , you can create custom date tokens, which let you match dates in various formats. When a custom date attribute is then used in a pattern as part of an action, Hazel treats it as a date rather than text, which means you can transform it into a different date format if needed.

Note:  You can also create custom date attributes by exporting attributes from an  AppleScript or JavaScript .

For example, we can match any date in the form “2016-09-21” by using a date token. You can do this by dragging the “Custom Date  ” token into the pattern.

By default, Hazel will try and detect the date format for you. This is indicated by the “Automatically detect date format” checkbox. When checked, Hazel will try to determine dates in various formats as defined by your system.

If automatic detection fails to detect a date or if you need more control, you can uncheck the option and specify a pattern yourself. From there, customize the pattern by clicking/dragging in the date-related tokens below, combining them with any desired text (such as hyphens or slashes).

Once you’ve added a date token, you can click the tiny arrow on its right side to display a pop-up menu with options that let you customize it. For example, the pop-up menu for “Year” (“99”) tokens lets you specify two-digit (“99”) or four-digit (“1999”) years; “Month” tokens can be formatted as “12” (no leading zeroes for single-digit numbers), “12” (single-digit numbers padded with a leading zero), “Dec” (abbreviated names), or “December” (full names); and “Day” tokens can be formatted as “31” (no leading zeroes for single-digit numbers) or “31” (single-digit numbers padded with a leading zero). Like custom text attributes, custom date attributes must have a name. (To help you distinguish custom date attributes, Hazel prefixes their names with   when they appear in tokens or menus.) Click “Done” when you’re finished creating your custom date token.

You can reuse custom date attributes in other conditions in the same rule. For details, see “Reusing Custom Attributes in Condition Patterns,” just below.

In addition, you can reuse custom date attributes in actions within the same rule. When a custom date token is used as part of a pattern in an action, it acts like any other date attribute, in that you can reformat the date or adjust it as needed. One case where this is useful is when the original month is given as a number, such as “01.” When you reformat it, you can have it output in textual form, such as “Jan” or “January.” (And, of course, you can do the reverse, too). To learn how to formatting dates, see  Editing Date Patterns .

SEE ALSO

Using Match Patterns in Conditions

Custom Text Attributes

Custom List Item Attributes

Custom Table Attributes

Reusing Custom Attributes in Condition Patterns

Using Patterns in Actions

Using Custom Attributes in Actions