'is busy' error?

I have been a happy user of FineReader Pro on my Mac for some time. I usually batch process a number of files I have in DevonThink, usually between 10 and 50 at a time, using an Applescript (included below). Previously, FineReader Pro would process all of these seamlessly. Now, the process quits after just a few files, and I have to continuously restart it.

Just recently, I started receiving an error message, which stops the batch processing:

FineReader got an error: Could not execute the script because FineReader is busy processing a document. You can use the is busy command to determine FineReader’s state.

I have searched Google, without finding a good solution.

The script I am using is:

tell application “DEVONthink Pro”
set theSelection to the selection
repeat with theRecord in theSelection
set thepath to path of item 1 of theRecord
tell application “FineReader”
repeat until not (is busy)
end repeat
– add ocr text layer underneath and compress
export to pdf thepath from file thepath export mode text under image with use mrc

		-- uncomment next line if you want text to be on top of image. Works well if scan is good quality
		-- export to pdf thepath from file thepath export mode text over image with use mrc without keep pictures
	end tell
end repeat

end tell


Perhaps this is related to my recent update to Mojave?

Or is there an error in the script?

Thanks!

Hi.

I don’t have either DEVONthink Pro or FineReader, but from the point of view of script design, I’d be inclined to keep the two applications’ ‘tell’ statements separate and not to make FineReader have to reply to a continuous stream of ‘is busy’ queries while it’s trying to carry out the task it’s been set.

It is possible that you’ll need to grant permission for the application running the script to control DEVONthink Pro and FineReader the first time it tries to do so in Mojave, but the system should explicitly ask if that’s what you want to do.

tell application "DEVONthink Pro" to set theSelection to the selection

repeat with theRecord in theSelection
	tell application "DEVONthink Pro" set thepath to path of item 1 of theRecord

	tell application "FineReader"
		-- add ocr text layer underneath and compress
		export to pdf thepath from file thepath export mode text under image with use mrc
		repeat while (is busy)
			-- Allow FineReader some breaks between answering 'is busy' queries.
			delay 0.5
		end repeat
            
		-- uncomment next line if you want text to be on top of image. Works well if scan is good quality
		-- export to pdf thepath from file thepath export mode text over image with use mrc without keep pictures
		-- repeat while (is busy)
		--	delay 0.5
		-- end repeat
	end tell
end repeat

Hi, Nigel-

I greatly appreciate your advice from a few months ago. I have unfortunately not been able to solve this by myself.

I just copied and pasted your suggestion, but when I tried to compile, I got the error message,

“Expected end of line but found “set”.”

The highlight pointed to the word ‘set’ in the command, ‘repeat with theRecord in theSelection
tell application “DEVONthink Pro” set thepath to path of item 1 of theRecord’

I tried to modify the script a number of times until it would compile, ended up with:

tell application "DEVONthink Pro"
	set theSelection to the selection
	repeat with theRecord in theSelection
		set thepath to path of item 1 of theRecord
		
		tell application "FineReader"
			-- add ocr text layer underneath and compress
			export to pdf thepath from file thepath export mode text under image with use mrc
			repeat while (is busy)
				-- Allow FineReader some breaks between answering 'is busy' queries.
				delay 0.5
			end repeat
			
			-- uncomment next line if you want text to be on top of image. Works well if scan is good quality
			-- export to pdf thepath from file thepath export mode text over image with use mrc without keep pictures
			-- repeat while (is busy)
			--    delay 0.5
			-- end repeat
		end tell
	end repeat
end tell

At this point, I compiled, then ran the script on a few files, and got the same original error message:

error “FineReader got an error: Could not execute the script because FineReader is busy processing a document. You can use the is busy command to determine FineReader’s state.” number 5.40094521E+8

I realize you don’t have the FineReader program, but perhaps you could point me in the right direction so I could search to get some clues.

Thanks again!

It looks to me like Nigel’s script was missing a “to.”

Since we don’t have the applications, Nigel would be unable to compile and be informed of even minor typos.

Please try:


tell application "DEVONthink Pro" to set theSelection to the selection

repeat with theRecord in theSelection
	tell application "DEVONthink Pro" to set thepath to path of item 1 of theRecord -- "to" added to this line

	tell application "FineReader"
		-- add ocr text layer underneath and compress
		export to pdf thepath from file thepath export mode text under image with use mrc
		repeat while (is busy)
			-- Allow FineReader some breaks between answering 'is busy' queries.
			delay 0.5
		end repeat
            
		-- uncomment next line if you want text to be on top of image. Works well if scan is good quality
		-- export to pdf thepath from file thepath export mode text over image with use mrc without keep pictures
		-- repeat while (is busy)
		--	delay 0.5
		-- end repeat
	end tell
end repeat



Oops! Many apologies, sawxray. I should have seen that. I must be getting older than I thought. :expressionless: Thanks for spotting the omission, t.spoon.

I see I’ve also moved the is busy repeat to after the export (or is it export to pdf?) command on the assumption that it waits for the command to complete and that it doesn’t matter either way in the context of the main repeat. But it may be worth trying with the inner repeat back in front of the export command so that even the first export isn’t attempted before FineReader’s ready.

I’ve just been looking at FineReader’s Web site. It urges users to update to the latest version that’ll run on their systems in order to avoid incompatibilities and known bugs. There’s a tutorial on how to use Automator with FineReader (https://support.abbyy.com/hc/en-us/articles/115005902149, but nothing about AppleScript apart a hint that FineReader supports it.

It’s interesting that your error message says “Could not execute the script…”. Is the script being run from a menu in FineReader, or is it run from outside? Does it work when there’s only one file to process, or does it fail even then?

I presume you’ve looked at FineReader’s scripting dictionary in Script Editor (or Script Debugger). Does is busy definitely return a boolean? It looks as if it should, but does the dictionary entry explicitly say so? Also, following a thought of my own inspired by the Automator tutorial, would it be possible to post the full dictionary entry for export (or export to pdf, if that’s what it’s called) here? If it’s possible to pass a list of files to process, there may not be any need for a repeat, apart from a vanilla AppleScript one to convert the paths to aliases. Just a thought.

If your original script used to work but stopped doing so after a system upgrade, updating FineReader is the first thing to try.

Thank you both again for contributing.

I have tried the latest script from t. spoon, and then made my feeble attempts at editing and finding the issue, without luck.

Going back to that script, I get the ‘Script failed…’ with the following error message:

Error Number: 540094521

FineReader got an error: Could not execute the script because FineReader is busy processing a document. You can use the is busy command to determine FineReader’s state.

Any thoughts on what I might next try?