Using Patterns in Actions

For certain actions (including “Rename,” “Sort into subfolder,” “Add comment,” and “Display notification”), you must specify a pattern—a template of text and special attributes. The action uses your pattern to generate text when it runs. For example, when renaming a file, you can add the date the file was added. Since you don’t know what the date will be until the rule runs, and that the date varies from one file to the next, you can use an attribute in your pattern to represent that date. When the rule runs, it substitutes the actual date.

When you choose an action that requires a pattern, a popover appears as shown here. (Note that the available attributes vary from one action to another.)

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 attributes of the file being matched. Using a token in your pattern tells the rule to substitute that item’s actual value when the action runs. To add a token to your pattern, either click it (once) or drag it to the desired position in the pattern. The “Example” field at the bottom of the popover shows a sample of how the pattern will look when the action runs (of course, the actual text will vary). When you’re finished editing your pattern, click “Done.”

Special Attributes

A few attributes have special behaviors when it comes to patterns:

- “Other”: “Other” is a stand-in for any available Spotlight attribute. When you add it to the field, a popover appears in which you can select which Spotlight attribute you want that token to represent. Depending on the attribute, you may have more options available after adding it to your pattern.

- “Add Tags,” “Remove tags”: When you choose one of these actions and click in the field, a pop-up menu appears. You can choose either a specific tag name (click “Show All” if the one you want isn’t visible), Any Existing Tags (for the “Remove tags” action), or Dynamic Tag , which lets you build a pattern from text and tokens, much like the one shown above.

Attribute Formatting

If you hover your pointer over any attribute after adding it to the field, you’ll see that an arrow appears on its right side. This indicates you can click the token to display a pop-up menu with more formatting options. Depending on the type of attribute, you may see one or more of the following options:

- For any attribute:

- Choose “Replace text” to configure simple find-and-replace pairs (for example, “Replace jpg with JPEG ”), which alter the text from what it would otherwise be. You can have more than one such pair if needed.

- Choose “Set default” to set up a default value for that attribute. If the attribute is blank/empty, then this default value will be used instead.

- For text-based attributes: Use the commands “No change,” “Title Case,” “lowercase,” or “UPPERCASE” to change the capitalization of the text.

- For number-based attributes:

- “No change”/“0”/“00”/“000”/“0000”; “Edit Number Format”: You can set the minimum number of digits. If you want to include leading zeroes so that all numbers are padded out to the same number of digits, choose the minimum number of digits you want the counter to have: 0 (one), 00 (two), 000 (three), or 0000 (four). Note that this is only a minimum; the number of digits you choose here doesn’t prevent the counter from incrementing past it. If you need to use a larger number of digits than four, choose Edit Number Format and use the arrow buttons to set the desired number of digits.

- “Adjust Number”: If you want the adjust the actual number up or down, you can add or subtract any number from what the attribute would otherwise be. To do this, choose Adjust Number and then use the arrow buttons to set a positive or negative value.

- For attributes representing a list (such as “Other” > “Attachment Names,” “Keywords,” or “Performers”):

- “First Item,…,Last Item”; “First Item”; “Last Item”; “Select List Item”: Choose one of these commands to use only use the first item, the last item, a specific list item (such as the second from the beginning or ninth from the end), or all items, separated by commas (the (First Item,…,Last Item” option).

- “Text Format”: This submenu displays the same capitalization options that appear for text-based attributes. Note that this format applies across to items in the list.

- For attributes representing dates:

- “Edit Date Pattern”: Change the way the date is formatted by using a wide variety of tokens (plus manually entered characters) to create your own pattern. See Editing Date Patterns for more information.

- “Adjust Date”: Choose this command to add to or subtract any number of years, months, days, hours, and/or minutes from the date.

- For domains: The “domain” attribute has special options to indicate how much of the domain to show: “www.example.com” (the whole thing), “example.com” (bare domain only, no subdomain), or “example” (the portion of the domain before the dot and top-level domain).

SEE ALSO

Using the Counter Attribute

Editing Date Patterns

Action Reference