OCR Script Now Broken in New Hazel?

I have used Katie Floyd’s AppleScript in Hazel to OCR documents using PDFPen and then move them. But since upgrading to MacOS Big Sur and upgrading to the newest version of Hazel, it is causing problems. It gets to the OCR stage, opens PDFPen, OCR’s the document, and then repeats itself in a continuous loop until I stop it. Any suggestions on what could have broken with the upgrades? I don’t know AppleScript well enough to troubleshoot it. Any help would be much appreciated. Thank you.

I’m using the version that Rosemary Orchard posted on this forum a couple of years ago when Katie Floyd closed down her website. So far this has been working without a problem in Hazel v4 and then v5 when I upgraded a week ago. I don’t know of Rosemary’s version has any alterations from the original post Katie made but it is still working reliably in Hazel 5.

1 Like

@djmerrill here my PDFpenPro Script, which works in the current macOS Big Sur with Hazel 5:

tell application "PDFpenPro"
	open theFile as alias
	-- does the document need to be OCR'd?
	get the needs ocr of document 1
	if result is true then
		tell document 1
			ocr
			repeat while performing ocr
				delay 1
			end repeat
			delay 1
			close with saving
		end tell
		--In PDFpen, when no documents are open, window 1 is "Preferences"
		--If other documents are open, do not close the App.
		if name of window 1 is "Preferences" then
			tell application "PDFpenPro"
				quit
			end tell
		end if
	else
		-- Scan Doc was previously OCR'd or is already a text type PDF.
		tell document 1
			close without saving
		end tell
		--In PDFpen, when no documents are open, window 1 is "Preferences"
		--If other documents are open, do not close the App.
		if name of window 1 is "Preferences" then
			tell application "PDFpenPro"
				quit
			end tell
		end if
	end if
end tell

6 Likes

Hi

I have an unusual situation - I actually want to use pdfpen to automate removal of the OCR layer instead of adding OCR

is anyone able to help me with this? I am happy to pay if someone is genuine since it is for business purposes

Perfect my script stopped working and now I am up an running with this slightly changed script (Feb’22)

1 Like

Sorry, I do not see the new script that you mention in your post

I don’t remember anymore but it must be this one

tell application “PDFpenPro”

open theFile as alias

tell document 1

ocr

repeat while performing ocr

delay 1

end repeat

delay 1

close with saving

end tell

tell application “PDFpenPro”

quit

end tell

end tell
Capto_Capture 2022-09-26_11-49-18_PM