Smart Rule wildcards

I have a few simple smart rules that apply to some items I add to DT3. One of them adds a date to the beginning of emails (2020-12-21 - Email title) and some documents. Occasionally the item may already have a date appended to the beginning of the title and, of course, the smart rule adds another. I have been trying to add a condition that checks to see if there is already a date before appending another.

I understand wildcards will only work with a Match, there is my problem. How would I set this up to detect the date and only add another if it was absent?



In what format?

As in the format shown above "YYYY-MM-DD - "


You could ty this approach…

Thanks, I’ll try that.

OK, that appears to work fine. I’m assuming the exclamation mark means ‘does not match’. Is that correct?

Thanks for your help


Yes the exclamation point negates the match. And you’re welcome.

Hi there, I found this topic. This was exactly what I was looking for, but I would like to drive it a little further.

Is there a way to delete numbers and symbols at the beginning of the name?
For example I have a file that has a “wrongly” formatted date at the beginning and I want to replace with my formatting.





And I would like to change it to be


this smart rule can prefix the date but I can not figure how to delete parts.

Also I just recognized that the Rule


Doesn’t make a difference between - and _ as separator so 2021_12_19_ and 2021-12-19- would be correct. Is there a way to only consider 2021_12_19_ as a correct prefix?

Thanks in Advance

A screenshot of your rule would be helpful.

Hello Jim, I also have a question when using Smart Rule wildcards. I assume the answer is “no”, but just to be sure:


Is there any way to specify the number of matches, instead of manually repeating each instance? For example, using [0-9]{4} (à la regex) instead of [0-9][0-9][0-9][0-9]?

It is basically the rule as mentioned above.

Is there a documentation of all the functions that are available in smart rules and what operators are available i.e. checking for letters, special symbols etc.

The help only describes what the function does but not how to make them doing that.

You’re using a regular expression in a search. That does not work, you have to use a scan rule.
The normal search does not recognize regular expressions.

Ah okay, could you please show me an example of what you mean I am new to Devonthink and right know I can’t figure it out.

My rule actually finds everything that doesn’t start with 2021_12_19_ or 2021-12-19- format

I would like narrow it down to really operate everything that doesn’t start with 2021_12_19_[letter] so using underscores and having a letter after the date.

Next step would be to to delete everything before the first real letter and replace it with the date.

Did you read the documentation on smart rules? The usage of scan text/name is explained there.


I checked the help file there the function of scan name with string, date etc is mentioned. But no syntax how to use it. At least not that I was able to figure it out.

I am really not trying to play the lazy card here I would love to understand and do it myself.

I have to say I am not that experienced in programming of any kind. I have just very basic knowledge in that field.

OK, I’m quotng the relevant parts from the documentation.

Item scanning: The next two actions allow you to scan the name or text of a document and use the results when found. …

  • Scan Name: Scans the name of the file.

    The following four parameters are used with the Scan Name and Scan Text 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.

So you have to use a regular expression, because it is not possible otherwise to refer to parts of the match.
The expression itself should look like this
and the replacement like this

Explanation: \d is RegEx’ish for [0-9], think of “digits”. So we’re first capturing 4, 2, and another 2 digits in the capturing groups (delimited by parenthesis) 1, 2 and 3. Then comes a non-capturing group (?:...). It looks for an optional (?) underscore, followed by four digits (\d{4}). The last capturing group is (-.*), i.e. the “-Name” part in your example. This group is # 4, since non-capturing groups are not counted.

In the replacement part, you simply string together the capturing groups 1 through 4 with the underscores you want.

Since the rule only matches the file names you described, it should do what you want. Please test first with a copies! And adjust the rule accordingly if the part after the date is not four digits…

1 Like

Not in criteria, it’s not possible at this time.

In the Scan Text or Scan Name smart rule action, it is when you use a Regular Expression method. However, the smart rule would have to identify the matching files first.

1 Like

Thank you very much I will try it out. That really is something new I didn’t find. I will also check the help again to see where I missed what you posted.


It is in the link to the ICU definition.

Thanks for the confirmation!

1 Like