Smart Rule: Add Tag that is a string in the document

Hi,

I’m new to DevonThink. Is there a way to add via a smart rule a tag from a string in the document?
I know how to use the smart rules feature, but I don’t know if DT can add such a tag.

In concrete terms, I want to create a smart rule like this:

If content is [year] (I guess I have to enter for year “[0-9][0-9][0-9][0-9]”, so that DT searches the file for a year)
Then add tag [year] (the year [0-9][0-9][0-9][0-9], so that it automatically adds the year DT found in the file)

Thank you!

This is described on page 259 of the DT manual

As Cambrian already said it’s described in the documentation. Which is excellent and a good point of first research. In your case, the smart rule might look like this (untested):

I’d be wary of the Regular Expression in this case, though: It will pick up any 4 digit run in the text. You might want to change it so that is more specific, like ([12]\d{3}) which picks up any 4 digit run starting with 1 or 2.

1 Like

Oh, I guess I searched at the wrong place in the documentation.
Thank you both so much!

The cool thing about regular expressions (at least I think so) is to ‘solve’ your puzzle with the best match, so DT finds that piece of text you actually want.

As @chrillek mentioned, the regex in that example will match any 4 digit number. That might be good enough, if the text you’re searching doesn’t contain year-like numbers except the year you’re looking for (which could be unlikely).

Depending on your situation you might simply start your search with 20, but if the years you’re looking for are historic that obviously won’t work.

In the end, keep in mind DT isn’t aware of the context. It will regard the number 2020 an equally good match whether it’s a year or 2020 paperclips. Though sometimes you can solve that with a leading text like ‘Year’ or some other text relation that’s always occuring. Good luck!

1 Like

The easiest solution is usually the “Add Tags from Document” action which supports multiple entered tags. All tags found in the text of the document are added.

2 Likes