Convert OCR mit Applescript

Hallo zusammen,

ich habe versucht meinen Workflow zu verbessern. Aus diesem Grund wollte ich ein Script erstellen, dass erst das PDF mit OCR konvertiert und automatisch den Namen/Tags vergibt.
Probleme habe ich nur mit der OCR Konvertierung.
Führe ich das Script via DEVONthink aus, kommt bei “convert image record” immer eine Fehlermeldung: “DEVONthink Pro got an Error: AppleEvent timed out”.
Führe ich da Script im Script Editor aus, wird ein PDF+Text ohne Fehler erstellt.

Ist es ein Fehler in DEVONthink oder muss ich nur das Script nur anders schreiben, um kein Fehler zu bekommen?


tell application id "DNtp"
	try
		set theSelection to selection
		if theSelection is {} then error "Please select some contents."
		
		repeat with thisItem in theSelection
			if type of thisItem is PDF document and word count of thisItem is 0 then
				set thisNewItem to convert image record thisItem with waiting for reply
				move record thisItem to (trash group of database of thisItem)		
			end if
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

In diesem Thread geht es um ein ähnliches Thema. Das Script aus diesem Thread hat bei mir leider auch nicht funktioniert.


-- The Right Way To Do Convert to Searchable PDF
-- Created by Annard Brouwer on Good Friday 2008.

tell application "DEVONthink Pro"
   activate
   try
      set thisSelection to the selection
      if thisSelection is {} then error "Please select some scans."
      repeat with aRecord in thisSelection
         with timeout of 3600 seconds
            try
               set newRecord to convert image record aRecord
               set name of newRecord to name of aRecord
            on error errMsg number errNo
               if errNo is equal to 9104 then
                  log message errMsg info (name of aRecord) & ": Check “~/Library/Caches/DEVONthink Pro/OCR” for files that weren't imported"
               else
                  log message errMsg info (name of aRecord)
               end if
            end try
         end timeout
      end repeat
   on error error_message number error_number
      if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
   end try
end tell

Danke für eure Hilfe

MacOS Sierra 10.12.2 (16C67)
DEVONthink Office Pro 2.9.8

Have you tried your script without the “with waiting for reply” parameter? This might be what is causing the script to time out.

Yes i tried. In the second script there is not the “with waiting for reply” parameter and the script makes the same error.

If a single document, how big is the document you’re trying to process - megabyte and page count?

Otherwise, how large of a selection are you trying to process?

File size less than 1 megabyte
Page count: 1 - 2 pages

I have only selected a document for the ocr script.
As soon as the script has arrived at “convert image record” comes the time out.

This seems to be another issue of Sierra, version 2.9.9 will include a workaround.