Apply a label to files without three-letter prefixes?

I use a set of three-letter capitalized prefixes for my DEVONthink files as system of file taxonomy (e.g., DOC_ - document ; ART_ - article ; NTS_ - notes, etc.) for certain crucial files.

I have even set a label in my DEVONthink that I manually apply to files that lack any of my prefixes so that my file taxonomy system works, and I can quickly spot and identify my files.

Is there a way to create a script to that can automatically apply my label to files within certain groups that lack one of the three-letter capitalized prefixes for my files?

Thanks!

What does within specific groups actually mean? Groups with unlabeled notes, groups with unlabeled documents, or groups with a mixture of all three?

Yes, all of the above — and beyond.

The thing is, I often use these prefixes — for many files — but sometimes I’ll jot down a quick, informal document without a prefix, and that’s ok. Although maybe my right brain would disagree!

I use an Applescript to assist with assigning filenames, tags etc
Do you have a clearly defined set of rules for this?

1 Like

Automation needs uniformity to be reliable. Consistency in filenaming and well-reasoned procedures in filing would be two key pieces.

Right. So, let’s say I have article files in a Group that lack the ART_ prefix. Could I set up a Smart Rule that would automatically label these files?

If that’s possible, perhaps could apply such a Smart Rule to a set of Groups in which I reliably have files with my prefix taxonomy – thereby automatically labeling files that lack the three-letter capitalized prefixes (again, if possible).

Would that work?

I don’t understand any of this, but the AI does. If it works with regex, then maybe like this?

^(?!.._).*

You aren’t providing any information on how an automation would know to use the ART label… or any other label.

Also, you can’t target multiple groups with a smart rule. You could replicate items in groups to a single targeted group.

As so often, the AI doesn’t help either here. Unfortunately, it’s not even aware of that.

I take your point. I’m basically seeing if there’s a way to create automation based on the absence of something, which is I guess the challenge. Ok, so about about this…

Could I set up automation – script or Smart Rule – in which I say, if files don’t have the following (prefixes) …

ART_ ; DOC_ ; MMO_ ; ITS_ ; NTS_ etc.

… then apply this Label?

Let’s start with that.

With regex you should be able to search for such names (strings) or exclude them. If the AI does not do this correctly, someone else (human) certainly does. Unfortunately, I don’t know whether this is enough to automate it. :slightly_smiling_face:

A negative look-behind regular expression might do the trick. Right now, I can’t tell you more because I have only my iPhone with me. But the Net should know what there’s to know about it. Something like
(@@@(ART|DOC|MMO)_).*
Where (@@@ is a placeholder for negative lock-behind.

But as @DTLow said, you’d have to use that in a script setting the label only for file matching the RE.

With Applescript, something like:

if not filename-prefix in {"ART_","DOC_","MMO_","ITS_","NTS_"} then

What label (prefix?) are we applying

1 Like

As I said, I have no idea. But this test seems to show that nothing is found that starts “xxx_”.

That’s a good starting point. But the RE it’s far too general – it also matches x2x_ and ____, for example.

As @DTLow asked about, I further the commentary… No. :slight_smile: …unless these documents are all segregated in their own groups or you provide some matching criteria. How would the automation know what label to apply without you explicitly telling it by providing something to say This is a Note. This is a document., etc.? Imagine you send me the group of your documents and said, “Jim, please label these documents. I’ll be back in an hour to pick them up.”, then left. You’d come back to either something done wrong or nothing done at all, because you gave me no instructions on how to determine what label to apply.

1 Like

Gotcha. Makes sense. Ah well… Never hurts to ask!

Thanks for all of your help, everyone.

Are you using the Pro version of DEVONthink? If so, I’d suggest you consider removing the prefix from the filename and moving it to a custom metadata field called, for example, “type”.

This has two main advantages: A Smart Folder or Smart Rule could use the simple condition Type Is "" to display/apply to items without a taxonomy indicator.

And when you link to a file or quote from a file, you will only see the actual filename, not “DOC_filename”.

That’s how I would do it, but like I said, it’s just a suggestion.