Hi
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?
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.
Like:
202112191200-Name
or
20211219_1200-Name
And I would like to change it to be
2021_12_19_Name
this smart rule can prefix the date but I can not figure how to delete parts.
Also I just recognized that the Rule
![0-9][0-9][0-9][0-9]_[0-9][0-9]_[0-9][0-9]
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?
Hello Jim, I also have a question when using Smart Rule wildcards. I assume the answer is ânoâ, but just to be sure:
![0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
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]?
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.
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 (\d{4})(\d\d)(\d\d)(?:_?\d{4})(-.*)
and the replacement like this \1_\2_\3\4
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âŚ
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.
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.