How does batch processing work?

Some of the functions are pretty obvious, but I haven’t been able to figure out what “scan text” and “scan name” do. Are they for selecting a subset of files, or do they feed a dynamic placeholder?

I’m not sure that this reply will be much help for you because I rather assume you’re the sort of person who will already have checked the user guide (also available through the in-app Help), so please forgive me if you’ve already looked at this. However, just in case, and from page 242:

Apologies if I’ve completely missed the point!

Stephen

2 Likes

Stephen, I appreciate the link.

I have a blind spot for obvious things. I think it’s kicking in here.

Here’s part of my confusion, although it seems like it should be clear:

These actions and parameters can be used with subsequent actions that support placeholders, e.g., Scan Text: Date → Document DatewithChange Modification Date. If the action returns no results, actions using the results will not be executed. However, unrelated actions in the smart rule chain will be executed normally.

How do I “use the results”? For instance, if I use “scan name” with the parameter “file*”, I assume documents named in the form file 1, file 2, file 3, etc. will be processed if I “use the results” in a subsequent action.

It’s my fault. I can’t figure out how to access the results in subsequent actions and I don’t know if the results are the list of matching files or the text found.

I appreciate any tips.

One way would be to use regular expression’s capturing group and refer to them later on with “$1”, “$2” etc.
Another way is, afaik, described in the documentation, too:

Quoting from the “smart rule events and actions”:

"Item scanning: The next two actions allow you to scan the name or text of a document and use the results when found. Each of the actions also has a parameter you specify for the type of data you’re scanning for. These actions and parameters can be used with subsequent actions that support placeholders, e.g., Scan Text: DateDocument Datewith Change Modification Date. If the action returns no results, actions using the results will not be executed. However, unrelated actions in the smart rule chain will be executed normally.

Scan Name: Scans the name of the file.

Scan Text: Scans the contents of the file.

The following four parameters are used with the Scan Name and Scan Text actions. With String, Date, and Amount, a prefix and/or suffix before/after the wildcard has to be specified.

String: An asterisk (*) wildcard specifies data to be captured. Other terms added will be used to help located the desired string. In subsequent actions, use the Document String placeholder to represent the captured string.

Date: Similar to String parameter, use the desired format of the Document Date placeholder to represent the captured string in subsequent actions.

Amount: Similar to String parameter, use the desired format of the Document Amount placeholder to represent the captured string in subsequent actions.

Regular Expression: Items in parentheses are captured; items outside parentheses are ignored. You can specify multiple captures in an expression. Using the captured text in subsequent actions is specified by using backslash, \, and the number of the capture, starting at 1. Note we use Apple’s NSRegularExpression which supports the ICU regular expression syntax.

Example:

Using the String parameter, Invoice * would capture 0012345 in a file named Invoice 0012345..
Using the Date parameter, * would capture the date in a file named 2020-01-01.
Using the Amount parameter, $* would capture the dollar amount detected.
Using the Regular Expression parameter, Bill To: ([A-Za-z0-9 ,]+) would capture the name of the person or company billed. \1 would be used in the subsequent action."

1 Like

Thanks, chrillek, I appreciate your response.

I’m starting to get somewhere.

I highlighted six markdown files. Two of them had the word “select” embedded in the document with words following the target string, “select”.

If I batch process them doing a scan text/regular expression of select (.*) followed by an action of add tags $1, all six get the tag $1. Not what was in the placeholder, the literal text $1, and not just the matching files.

If the action is tag with \1, then only the two matching files get tagged with the tag \1. Again, that’s the literal \1.

If the action is mark as locked or flagged, none of the files are locked or flagged.

However, if the action is tag with “\1” or ‘\1’, tags are added with the words following “select” in each file, plus the quotes. If the word bingo follows select, tagging with “\1” results in a tag called “bingo” with the quotes included.

Some of the actions, like mark as flagged or locked, seem to always apply to all files selected.