If you define a custom attribute in a condition, that attribute is available to subsequent conditions. The attribute is effectively shared between all the conditions that use it. You can even specify different patterns for each case.
The first time the custom attribute successfully matches, it retains that value for the rest of the rule. That means subsequent uses of that attribute in the same rule must match the same value for any given file or folder.
For a text attribute, the exact text must match in subsequent usage. (The pattern for that token is ignored.) For a date attribute, a pattern can still be used to transform the text into a date, but the resulting date must match the previously matched date.
Take, for example, the following:
Although you can’t see it in the main rule interface, each use of the custom attribute has a different date format. The top one is formatted as 1999-12-31 (below, left), and the bottom one is formatted as December 31, 1999 (below, right).
Using a custom attribute like this enables you to match dates that may appear in different formats. In this example, you can match dates like August 31, 2015 or 2015-08-31 in the same rule. Since the pop-up menu above the conditions is set to “Any,” only one of the conditions needs to match. If you use the same custom attribute in an action for this rule, it will have the value of the first condition that matched.
Now let’s look at another example:
Again, it’s not shown in the main rule interface, but the custom attribute “parent folder name” here is defined as matching anything (…). The first instance matches the name of the file’s parent folder, as indicated by the pop-up menu (“its enclosing folder”) in the nested condition. The second instance matches the name of the file itself. The first time it matches, the name of the parent folder is captured into the custom attribute. When the custom attribute is used again in the second case, it must match the text that was captured before (note that the rule is set to match “All”). So, this example essentially matches a file if its name is the same as its parent folder’s name.
Using custom attributes in this way opens up new possibilities for correlating a file withs its parents or siblings, or correlating a folder with the files inside it.