Smart rule problem

Hi there
A few years ago I had a lot of help on here getting my smart rules set up for filing receipts. They have been working well for quite a while. I have been setting up some new ones and something has gone wrong ! When I run this one I get this error message
“Do you really want to perform rule " .eml to .pdf and OCR” on 0 matching items
in the opened databases?"

the same message appears for all of them !

I am not understanding what it is trying to tell me ! Can anyone help ?
Thanks
Dorothy

Please post a screenshot of the rule.

May I ask why you’d be doing OCR on PDFs produced from emails which are almost always going to be text-based?

Hi there @BLUEFROG
Many of my emails will include receipts for items purchased and have links to web sites etc. That particular rule was set up by the late @blanc. He spent a very long time helping me to understand how to do it.
I must have altered something in the background because I’m getting the error message for all of the rules.

This is the error message I get

Chrillek asked you to post a screenshot of the rule(s), not the error message :slight_smile: We need to see how the rule itself is configured. What you see when you right-click and choose Edit…, like this:

The error message just says there are no items matching the conditions specified in rule. That is, there are no items for the rule to act on.

Maybe some of the new rules you set up conflict with the old ones in some way. Like, they change something on the relevant items so that they no longer match the conditions specified in your old rule.

1 Like

Thanks @troejgaard I didn’t post the rules as I have more than 20 and the result is the same for them all. However, as requested I will post the first rule and the script prepared by the late @blanc

on performSmartRule(theRecords)
	tell application id "DNtp"
		try
			# show the progress indicator and allow you to cancel if required
			show progress indicator "OCR" cancel button 1 steps count of theRecords
			repeat with theRecord in theRecords
				if type of theRecord is PDF document then error "Adapt your smart rule to exclude PDF. Process failed to avoid looping."
				# cancel if you click the X in the progress indicator
				if cancelled progress then error number -128
				step progress indicator (name of theRecord) as string
				# set the requisite variables
				set theName to name of theRecord
				set theDatabase to database of theRecord
				# perform conversion to PDF and move the original record to trash
				set thePDF to convert record theRecord to PDF document
				move record theRecord to trash group of theDatabase
				# check to see whether OCR needs to be performed
				if word count of thePDF is 0 then
					# do OCR and delete the intermediary record
					set theFile to path of thePDF
					set newFile to ocr file theFile to parent 1 of thePDF type PDF document
					set name of newFile to theName
					delete record thePDF
					# tell DT to treat the document as if it had just been imported
					perform smart rule trigger import event record newFile
				else
					perform smart rule trigger import event record thePDF
				end if
			end repeat
			# handle any errors
		on error error_message number error_number
			hide progress indicator
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		end try
		hide progress indicator
	end tell
end performSmartRule

First thing I notice is “Search in” is set to “INBOX” all uppercase. On my DT the global inbox and database inboxes are all “Inbox”. Have you renamed the INBOX the rule points to or is this a special database called INBOX?

  • links to web sites wouldn’t need OCR.
  • An email could have an extension of .emlx too, which wouldn’t be matched by your criterion. I would recommend Kind is Email instead.
  • How are you getting emails into the Global Inbox?
  • The script is converting the email, not an attachment. Is that intended?

Hi, I have Inbox, All Inboxes and INBOX ! I’ll try changing to Inbox which is the main one the others are indented !

Thanks @BLUEFROG
I’ll change the kind to Email.
I have split screens for mail and DT and I just drag the emails over. I have also gone to print in Mail and clicked save pdf to DT then I bypass this smart rule.

Tried all three and no difference I still get the same error message !

Changed to kind is Email but no difference I still get the same error message.

Here is a non-scripted variation that produces a PDF from imported emails. The OCR may be superfluous in some cases, but unless you’re adding 100+ emails at once, it shouldn’t waste too many cycles…

  • What operating system are you running?
  • Have you quit and relaunched DEVONthink?

Maybe we should take things one at a time.

You started by asking what the message means. Let me correct myself a little: technically it is not an “error message”, but a warning dialogue – I didn’t think about that distinction earlier.

It tells you there are no items matching the criteria specified in the rule for it to perform any actions on. I never got deep into the automation aspects of DEVONthink, but I guess it is possible for a smart rule to still perform certain actions even if there are no items to act on. The result might be different in that case, and this warns you before you proceed.

The only way I can get it to appear is by using Tools > Perform Rules in the menu bar and selecting a smart rule that has no items matching its criteria. Is this what you are doing?

(I don’t get this warning when using Apply Rules > … on selected items that don’t match the criteria of a rule. I don’t really understand why it only appears in one case.)

If what you are doing now used to work before, then something must have changed. With the information you have provided so far, it is difficult to figure out what. When did it stop working? What changed around that time?

Are all of the 20+ rules you mention related to email? Either way, if none of them work, they must share something in the reason why.

@saltlane I think you’re getting confused by the word “Inbox”. Look at the icon: the search location is not an inbox or a database – but a group with the name “INBOX” located somewhere. It does make me think… @Dorothy, have you made sure that the items you want the rule to work on are actually placed somewhere in the specified search location?

Also, since the rule is automatically triggered by On Import and Daily, have you checked that it hasn’t already performed its actions? Then there would be no matching items left for it to run on.

1 Like

I have never seen the message mentioned nor can I reproduce it at will, hence my inquiry into the OS and the relaunching of DEVONthink.

That being said, I think my replacement smart rule would provide the same essential behavior and is more understandable to the layperson.

I didn’t mean to discount your rule. It is certainly much more approachable! And way easier to adjust down the line if you don’t know AppleScript.

But Dorothy says that all of her 20+ rules give this warning. Copying your rule hopefully works in this one instance, but it’s probably good to understand what is going on. If it fixes itself with a reboot/relaunch, no problem. But maybe she has missed something more general.

I do think I have seen this warning once or twice before in the wild. Now that I try, I can easily reproduce it. I just set up a smart rule that intentionally doesn’t match anything and select it in Tools > Perform Rules. A simple dummy:

“No images” is a test group I created in the Global Inbox. It contains only 3 markdown documents. No matter where I am, Perform Rules > Warning Test consistently gives me this:

SCR-20241118-ccrs

(It doesn’t display the alert if I click OK)

Do you see it if you secondary-click the rule and choose Apply Rule?

I just double-checked: no, I don’t.