Home | Appendix

|  |  | Smart Rules and Batch Processing

Smart rules are smart groups‚ evolved. Built in the same style as smart groups, smart rules don't just show items matching criteria, they can act on them! From something as simple as adding (or changing) a color label, to modifying a filename then filing a document in another location, smart rules provide some powerful automation possibilities. And they're not just for the technically inclined. No programming experience is needed for almost every action available. Smart rules are conceptually simple and can be summed up as follows: When this event occurs > do this action > on items matched > in this location. Smart rules are made of four parts: A location: This is where the smart rule will look for matching items. Matching criteria: Like a smart group, you can specify criteria to be matched. The smart rule will only act on the matched items. An action: This is the action the smart rule performs when the event occurs. An event: This is an event that causes an action to occur, e.g., an "On Quit" event. If used in a smart rule, a specified action would run when you quit DEVONthink. Create a Smart Rule Smart rules can be created in one of two ways: Click the + button at the bottom of the sidebar and choose New Smart Rule. The Search in dropdown will target the current location. Control-click an item in the sidebar and choose New Smart Rule from the context menu. This will specifically target that item in the Search in dropdown. Note in either case you can change the Search in parameter to target other locations, including all open databases.
Note: Smart rules are considered global objects and can be created only in the Navigate sidebar of a main window. If you want to create a smart rule for a group in the item list, choose Data > Reveal to display it in the sidebar.
When you create a new smart rule, you will be shown the predicate editor, just as you see with smart groups. Just follow these simple steps to define the parameters of the rule (with an example): Name: Give the rule a name, like Label Edited Screencaptures. Location: Set the Search in dropdown to target your desired location, like a group you add screen captures to. The more specific the better; a good idea is to use e.g., a database's inbox. Matching: Add any criteria to be matched, e.g., Name begins with screen and Kind is Image. Event: Choose an event to trigger the smart rule, like specifying On Save to run the smart rule when matched items are saved in DEVONthink Action: Choose an action for the smart rule, perhaps Change Name to add "_edited" to the name. This rule shown above would add "_edited" as a suffix to the name of any edited images whose name begins with "screen". One step further‚ chained actions: If you hadn't noticed, there's a + button to the right of the action you specified. And yes, that means you can chain multiple actions in a smart rule! For example, we could add an action to open the edited imaged in the system default application after it has been renamed. Understanding the input: In a smart rule, there always is only one input. You can't use conditionals or split the actions into a parallel process. A matched document is passed along through the entire process. So if you have a smart rule processing Markdown files and one of your actions is Convert to Rich Text, the resulting rich text file is created but not passed on to the next actions. The originally matched Markdown is still the input. However, there are two actions that allow switching the input: Duplicate & Continue and Convert & Continue. The items created by these actions become the input for the following actions. In our example, these actions would pass on the resulting rich text document as the input for the rest of the rule. Order of operations: If you have more than one smart rule targeting the same location and/or types of files, they will run in the order they appear in the Navigate sidebar. The topmost rule will execute first, then the second, and so on. Be aware one rule could make a change that affects whether an item is matched by subsequent rules. If it does, those rules logically will not process the items. Drag related smart rules into the order they should run or stop and reconsider how your rules are set up. Chaining smart rules: Creating smart rules with more limited functions is often useful. For example, a rule that just files documents based on a certain custom attribute can be used on selected documents or by drag and drop to the rule. Now say you have another rule with more complex functions, e.g., moving a document into a database, doing OCR, then adding custom metadata. Provided it's using the same custom metadata, instead of adding the same actions as the previous rule, add the Apply Rule action and choose the filing smart rule. Now add another smart rule that should also file things based on the same custom metadata but in a different location. Use the Apply Rule action there as well. Now both rules can use the filing smart rule's actions without having to redundantly add their own actions. This is a powerful way to extend the functions of a smart rule while also using the simpler functions, when needed. Importing and Exporting: Smart rules can be exported to the Finder, sent by email, and e.g., reimported to DEVONthink on another Mac. Drag a smart rule to the desktop to save it to a file or Control-click it and choose Export. Double-click a saved smart rule to import it, drag it into the sidebar, or Control-click into the sidebar and choose Import. Batch Processing Smart rules are useful for repetitious actions, usually happening in the background. For times when you need to make impromptu changes on specific items, e.g., prefixing a date to the name of several documents, batch processing is the best option. Select a few documents to process, then choose Tools > Batch Process. A small but familiar action editor appears where you can create the chain of actions, just as you do with smart rules. Then press OK and the documents are modified. Note not every smart rule action is available in batch processing. However, for most actions the available ones are more than sufficient. We hope this has given you a good overview of smart rules and batch processing. Please see the appendix for a complete list of available Events and Actions. For those interested in the Apply Script action, continue to the next section…