Trigger smart rule when filename is not prepended with date

I like to prepend some filenames with the searchable date followed by a space "YYY-MM-DD ".
I have a rule to file away files in INBOX prepended with the date by matching the regex “^[0-9][0-9][0-9][0-9]+[0-9][0-9]+[0-9][0-9]”.

When data is added added to the INBOX some names are already prepended others are not. I would like to create a smart rule that triggers on “kind” and not matching the regex to automate adding the date for data types where it is needed i.e.

All the following is true
kind is email
name does not match “^[0-9][0-9][0-9][0-9]+[0-9][0-9]+[0-9][0-9]”

The problem is that there is no "name does not match, only a “name matches” and, as far as I know, there is no regex syntax for a negative match. I could write a script instead but the nice thing about the smart rule is I can auto trigger it on data falling into INBOX.

Any suggestions?

1 Like

I also prefix filenames with yyyy-mm-dd

I use an Applescript to assist with processing Inbox entries
This includes filename, tags, …

1 Like

Did you read the Appendix > Search Prefixes section of the built-in Help and manual ?

Did you read the Appendix > Search Prefixes section of the built-in Help

Yes, There are examples there using NOT, !, and != but using any of those in the field to the right of name matches doesn’t make any difference. I still see a list of all the files that match the regex instead of the ones that don’t.

You must negate your regular expression, not the “matches” operator. The simplest condition would be ^[^0-9], i.e. the first character of the string is not a digit. Or, more succinctly: ^\D.
If you want to be more specific, you could use negative look-ahead:
^(?!\d{3}-\d\d-\d\d).*

NoteThe regular expression in your first post makes very little sense. If you want to match YYY-MM-DD, you should not use a + sign following the digits. Nor should you use four digits if you intend to match three digit years (why would you want to use three digits for years, though?). If, as I suppose, you want to match YYYY-MM-DD, use something like
\d{4}-\d\d-\d\d
i.e 4 digits, followed by a dash, two digits, another dash and two final digits. Also, \d is easier to read than the corresponding character class

Note:

  • When there’s no content in the Name matches field, it reads Operators & Wildcards. This does not support full RegEx for matches.

  • As noted in the documentation, dashes, dots, etc. are ignored and treated as spaces: Words separated by hyphens are handled like word1word2 OR "word1 word2".

  • Also matches is a substring match with no positional parameter, e.g., it matches anywhere in the name.

This smart rule detects any combination of YYYY MM DD or 8 digits…


You can use the Name without Date placeholder to strip detected dates in a name before prefixing…

Note the inclusion of a tag to ensure the documents are not matched again by the rule. This could obviously be another action, like Move or File.

This yields…
image

1 Like