Auto build smart rules

I have a lot of smart rules that are just to tag documents that contain a certain word or phrase and aren’t already tagged. I’d love to automate this somehow - does anyone know of a script where I could input a list of, say, 20 search terms/tag names and it would auto create the rules? is that possible?

1 Like

This isn’t possible, smart rules aren’t scriptable. But smart rules can execute scripts, maybe one smart rule using an embedded script could replace all your existing smart rules? A screenshot of one or two smart rules would be great.

1 Like

here’s a picture! they all pretty much look just like this.

The following smart rule might be an option:

The “Tags - Assign” script scans the documents added/modified during the last week for both hashtags and already existing tags. In case of case-insensitive tagging (see File > Database Properties…) and an existing tag named “roy barnes” the documents should be tagged as expected, therefore it’s possible to define tags only, not smart rules.

wait…it’ll go through ALL my tags and assign things immediately? sorry, i’m sort of amazed by this, so let me make sure i understand.

i add a tag, christian grunenberg. i don’t tag any document with that tag but it exists. i run this script. lt’ll go through and find every example of “christian grunenberg” and tag it? holy crap. that’s pretty amazing.

ok now two other clarifying questions (in case i did in fact get that right.) 1) what if i wanted it to find “christian grunenberg” and (christian NEAR/3 grunenberg). is there a way to do that automatically? i’m assuming no but worth a shot. (sub-question to this question – is there a way to do that by, say, making a tag that was “christian NEAR/3 grunenberg”? i probably wouldn’t do this, but just out of curiosity.)

  1. what if there are tags i don’t want it to find? e.g. i have documents that are tagged w/ the year they were published, but surely in that document there are other years listed. (i.e. the document is tagged with 1994 b/c published that year, but the text includes a reference to year 1991, and i have a tag 1991 that includes other documents published in 1991, but i don’t want my document published in 1994 tagged with 1991. is there a way to limit the tags this script takes on?

this is amazing. i hate myself for not realizing it earlier. thanks!

The extract keywords from with the with hashtags and tags command examines the title or text of a file and looks for…

  • Hashtags in the text
  • Words that match existing tags

This file has an explicit hashtag - someHashTag, two terms that are existing tags - mattis and gravida, one tag - testing - applied to the file that is ignored since it’s not in the actual text, and one tag - pulvinar - applied to the file that is reported since it’s also in the text…

And here is what the script returns for this file…

That’s correct (and thanks :slight_smile: )

Operators aren’t supported but aliases of tags are, you could e.g. add the alias C. Grunenberg.

Only by customizing the script and excluding e.g. 4-digit numbers.

okay i have no idea how to do that, but am hoping to get some help! could you customize it and only have it look for tags in a certain group, theoretically?

cool! so two questions - 1) this is a different script right? than the one christian listed? if so, what is the difference? it seems like they do similar things. i thought this keyword one was something about concordance…am i wrong?

  1. does it then tag the document automatically, or can i change the result (as it is on the screen) before the tags actually attach to the document?
  1. My snippet is the core of the script, showing the basic behavior of the extract keywords from command.
  2. No, neither has nothing to do with the Concordance.
  3. My code snippet does not assign Tags. That would be the behavior of the script Criss mentioned - and is a built-in external smart rule script.
  4. In the built-in script, it assigns tags automatically. There is no option to verify this first. Also, if this was applied as a smart rule script, that would be a bad design decision as it would keep on popping up a dialog to make this decision over and over again. Making that decision would be better made in a menu script, handled on a case-by-case basis.
  5. could you customize it and only have it look for tags in a certain group, theoretically?

Theoretically, but that would certainly require more coding as it’s not part of the core of the script.

Dumb question, but are smart rules only available on DT3?

Yes, this is a new feature of version 3.

Ok, here’s something I don’t understand about tags. I realize the above may be an example, but if it represents real world use… Why go through the trouble of tagging something as “roy barnes” when you can simply search for “roy barnes?”

I’ve attempted to use tags before, but found I was tagging the obvious: books, article, food, etc., which provides no real use that I could see. Given how many people like/want to tag, I must be missing something. Even something simple like “Invoice” wouldn’t provide any useful connection, as I put things like this into a folder for, well, invoices.

In my mind, I envisioned using tags to discern a deeper connection between documents. However, that would entail me tagging each document an assortment of tags, many of which may be abstract in nature. But then, I remember DT can do this already, so I’m missing the point of tagging.

What am I missing, because if there’s a more efficient way of document archiving, I’d like to know more.

Why go through the trouble of tagging something as “roy barnes” when you can simply search for “roy barnes?”

Because Roy Barnes may contextually relate to documents that don’t include his name.

Tagging is optional, not required. If they don’t make sense to use, don’t use them. Some people use a ton of tags. Would I approach things that way? No. But if that makes sense to them, it’s all good.
When I worked for Ironic Software, with Spotlight-enabled and dedicated software, I tagged a lot. With DEVONthink, I don’t tag very often outside of support purposes (though they are still useful to me).

So definitely be open to learning something new, but use DEVONthink in the way that make sense to you, not in the way others use it. (And that’s for everyone, including me!) :slight_smile:

Does that mean that the tag of “roy barnes” is used differently when tags are used in search?

I realize tagging is optional, I’m just trying to better understand a method which others use in hopes it would benefit me, too. I suspect my document management needs are not intricate enough to need something like tagging, but I still try to learn from what others are doing.

Does that mean that the tag of “roy barnes” is used differently when tags are used in search?

If you don’t use an explicit search prefix, like tags:, tags wil be included in the implicit All scope. Using the search prefix will target only tags.

I suspect my document management needs are not intricate enough to need something like tagging

I would dispel this myth from your mind :slight_smile: Tagging has absolutely nothing to do with the intricacy of your needs, and no one (yourself included) should feel it’s something for the intelligentsia, etc.

DEVONthink is fundamentally a simple application that can be used simply or in very complex ways. So here is a simple example:

Say you have a recipe database. You could tag a recipe or ingredient as Mediterranean, authentic, diabetic-friendly, or even yummy.

After tagging, you can search for yummy dishes, make smart groups of diabetic-friendly foods or ingredients, etc.

Nothing intricate at all.

Oh, I get that. And I understand the example. However, every time I look into tagging files, I end up tagging with the obvious, which is already contained in the document in some form.

Using the example above, if I had clipped an authentic Mediterranean, diabetic-friendly recipe, chances are all of that info would already exist in the recipe in some form (the words “authentic”, “Mediterranean”, and possibly even some form of “diabetic-friendly”). The way I file documents, anything that would be “diabetic-friendly” would get filed in the Diabetes group, and I wouldn’t actually keep a recipe if I tried it and it wasn’t “yummy.” And making tags for the ingredients seems superfluous as they’re already in the document.

The above is an oversimplification, yes, but it’s a good example of how my tagging goes. What I end up using for tags isn’t really needed in order to find the document because I’ve either filed it properly in DT or the data within the document is already enough to find it.

So when I come across people talking about their tagging system it makes me wonder how others are using it and how well it works. It’s not that I’m unhappy with DT’s search results (quite the opposite), but I keep my eye open for new ways to do things, especially if they’re efficient.

I think it’s good you’re open to learning. I can’t speak to the individual uses of tagging. I have run into many people who have tagged extensively, but never really used the tags. Perhaps others will weigh in.