Notifications and alerts using Document date placeholders for smart rules scanning for date

I’m trying to create a smart rule to use a date that’s embedded in a text document.

I’ve had so much trouble getting anything to work as expected that I decided to make as simple a test as I could devise.

First I created a plain text document named text document.txt containing just a single line. To avoid any possibility of misinterpreting a typed copy of the file’s contents, I’ve attached a zip archive containing it. [Really? You have to zip a plain .txt text file in order to attach it? :laughing: ]
Then I consulted the Devonthink 3.9.1 manual, where I read this:

Listed below are the supported date types with their raw value provided. Prefix the raw value with a date component as shown in the example below.



Current Date: Today’s date. There is no prefix to the raw placeholders for current date.
Addition Date: The date the item added to the database. recordAddition…

[embedded images removed]

Creation Date: The date the item was created. recordCreation…
Modification Date: The date the items was last modified. recordModification… Document Date: This is a date detected in the document’s contents, e.g., in a receipt. For PDFs only the first four pages are used. documentDate…

Newest/Oldest Document Date: The newest or oldest date detected in the document. For PDFs, only the first four pages are used. newestDocumentDate… and oldestDocumentDate…

Note: When using the raw values for
the date types, e.g., modification date, note the date component’s raw value will start with a capital letter. For example, use %recordCreationShortDate% not “%recordCreationshortdate%”.

Then I selected and copied %newestDocumentDateLongDate% from the manual, and pasted it into a smart rule action. When I paste it, the text changes to what you see in the rule action below:
Capto_Capture 2023-06-10_16-20-25_

But when I select the file and apply the rule, nothing happens.

So I changed the Display Notification action to Display Alert and re-pasted %newestDocumentDateLongDate%
to look like this:
Capto_Capture 2023-06-10_16-26-11_

When I apply the changed rule I get:
Capto_Capture 2023-06-10_16-36-52_

and that’s all.

Can these placeholders not be used in notifications and alerts?

Yes, placeholders can be used in a notification or alert.
Your date is invalid since it has delimiters.

Using the Document Date placeholder in the alert after using hyphens in the date…

And a simple RegEx variation with your version having spaces as well as M D instead of MM DD…

or a variation of the RegEx supporting spaces, hyphens, slashes, and dots: date ([0-9 ./-]{8,10})

I do appreciate your suggestion.

With regular expressions, of course, you don’t have the power to convert dates with a one digit day or month into a sortable date–at least, not with any regular expression that one could figure out without a Ph.D. in regular expressions. :grin:

Because I can see there are so many possibilities to deal with, and knowing a bit about parsing and scanning, I can understand that DEVONthink’s “Scan Text” “Date” would have some limitations. But perhaps some innovative way may be discovered so that more information could be put into the rule about allowable delimiters, and perhaps about the expected format of the date, and the prefix and suffix, to make this action able to work with delimiters. I know you can’t promise anything, but one can always hope.

JavaScript‘s replace method for string objects accepts a function as parameter that can, for example, add leading zeros to single digit matches. No PhD needed for that, but you’d have to do the replacing in a script attached to the smart rule.