Conditional File Naming

Hi folks! I’m new to DEVONthink and working to understand what I can do with SmartRules. My first simple project is vexing me. I’m hoping someone can point me in the right direction.

Basically, if a filename starts with the date pattern “YYYY-MM-DD FILENAME”, I want to import it with the name intact.

If the filename does not start with the date pattern “YYYY-MM-DD” I want to rename the file to using the creation date to place the date at the front of the filename. “YYYY-MM-DD FILENAME”.

I’m sure I’m missing something simple. Thanks for any guidance.

1 Like

It took A LOT of digging to finally figure it out. The answer was simpler than I realized.

1 Like

I have a more extensive set of file naming rules; also tag assignment
My solution is an Applescript, triggered by the import smart rule

1 Like

Welcome @roba1701
You should not have criteria-less smart rules. At a minimum, Kind is Any Document is advisable. You should strive to be as specific as possible with automations.

Basically, if a filename starts with the date pattern “YYYY-MM-DD FILENAME”, I want to import it with the name intact.

This doesn’t need to be considered as the only function of the rule is to change the name when it doesn’t match. File with names beginning with four numbers-two number-two numbers will not be matched and import as-is.

If the filename does not start with the date pattern “YYYY-MM-DD” I want to rename the file to using the creation date to place the date at the front of the filename. “YYYY-MM-DD FILENAME”.

1 Like

Thanks. I have lots to learn yet about AppleScript. :face_with_monocle:

Thank you. I will give that a whirl. Are there any resources with examples of SmartRules use? I’m trying hard to come up to speed.

A few things…
These forums have plenty of examples. There’s also the Scripts > More Scripts > Smart Rules where you can install extra smart rules. Just duplicate them and dissect / edit them .

Some stuff on our blog, including this…

PS: There’s no need to rush into things, especially if you’re new to DEVONthink. Go at a comfortable pace and use the app the way you need to use it now. Automations should come after you’ve established actual processes you can do manually.

2 Likes

Great. Thanks so much.

1 Like

FYI. If I run it on demand, it changes an existing filename that already has a YYYY-MM-DD set. The match is not working?

It did what you told it to do… on demand.

But if the rule states not to process a file if it starts with a sortable date, why do all my files with sortable dates show up when the rule is highlighted? It doesn’t make sense. Shouldn’t it only select file names that don’t start with a sortable date? What am I missing here? I was a DBA and I’m confused. LOL

I’m not looking at your computer so I can’t see what you’re talking about.
Screen captures or a screencast would be helpful. If you don’t want to share it publicly, open a support ticket and attach them.

2 Likes

Done. Thank you, Jim.

1 Like

Problem solved. Needed to negate the pattern with a “!” in front.

e.g. name matches ![0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]

Indeed and it’s a matches not a begins with that supports wildcards and operators, e.g., [0-9]. That was my incorrect reply earlier.

1 Like