Custom List Item Attributes

Although conventional attributes make it easy to create a condition that matches exact text (for example, in a filename) or a user-defined pattern, sometimes you may want your pattern—or an element of the pattern—to match any item from a list. For example, if you frequently work with files that include color names, you might want one condition that matches any of the words  red green , or  blue  while another condition matches any of the words  cyan magenta , or  yellow . Or, you might want a rule to take action on all files that include the name of any employee in your department, or the name of any musical instrument in an orchestra. For situations like these, you can create your own list item attribute. Any item on the list then matches that attribute in your match pattern.

To create a custom list item attribute:

  • Create a condition with an attribute (such as “Name,” “Extension,” or “Contents”) that uses a match-related verb in the second pop-up menu (“matches”/“does not match,” “match”/“do not match,” or “contain match”/“do not contain match”).

  • Drag the “Custom List Item (—)” token to the pattern field.

  • Type a name for your custom list item attribute.

  • From the “List Items” pop-up menu, choose one of the following:

    • “embedded”:  You enter the list items manually within Hazel.

    • “from file”:  Hazel uses the contents of an existing text file for the list contents.

  • Follow the instructions below for the method you chose.

To enter embedded list items:

  • Rename “Item 1” as your first list item. To do this, select “Item 1,” wait a second, and then click it again to make it editable. Type in the first list item. 

  • Add more list items. To do this, either select the first list item or hover over it and click the add   icon. Type the next list item; repeat as needed.

  • Your finished list may look something like the image below. When you’re finished, click “Done,” and then make any further desired changes to your match pattern.

To use list items from a file:

  • Click “Choose,” navigate to a text file containing your list, and click “Open.”

  • By default, Hazel assumes each list item is on a separate line. If the list items in the text file are separated with a Tab character, choose “Tab” from the “Items separated by” pop-up menu. You can also type a character, such as a comma, in the “Items separated by” field.

  • If you select “Trim blank characters,” Hazel ignores whitespace characters on either end of any text from a field in a list item.

  • Click “Done,” and then make any further desired changes to your match pattern.

To rename a list item:

  • Select the existing list item, wait a second, and then click it again to make it editable. Then type a new name and press Return.

To add a list item, do either of the following:

  • Hover over an existing item and click the add   icon.

  • With an existing item selected, press Return.

To reorder items in a list:

  • Drag them up or down.

To remove a list item, do either of the following:

  • Hover over it and click the remove   icon.

  • Select it and press Delete.

SEE ALSO

Using Match Patterns in Conditions

Custom Text Attributes

Custom Date Attributes

Custom Table Attributes

Reusing Custom Attributes in Condition Patterns

Using Patterns in Actions

Using Custom Attributes in Actions