Watching folder and OCR with FineReader Pro

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Watching folder and OCR with FineReader Pro Tue Feb 18, 2014 10:16 am • by Dr Mabuse
Hi,

I have tried to implement a workflow in Hazel where I watch a folder and OCR the content.

I have tried to modify the AppleScript using this script from Katie Floyd:
http://katiefloyd.me/blog/automatically ... and-pdfpen

Code: Select all
tell application "FineReader"
   open theFile as alias
   tell document 1
      ocr
      repeat
         delay 1
      end repeat
      delay 1
      close with saving
   end tell
   tell application "FineReader"
      quit
   end tell
end tell


The Hazel rule is as following watching the download folder:
If all extensions is pdf
Color label is not blue
Then Run AppleScript
Set color label to blue

At first the script opens FineReader and starts to OCR the pdfs, but the I get AppleScript failed message.

Can anyone help?
Dr Mabuse
 
Posts: 2
Joined: Tue Feb 18, 2014 9:58 am

Check the logs. Go to the "Info" pane and click "View Log" and look for the AppleScript error and post it here.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Code: Select all
2014-02-19 10:50:20.947 hazelworker[62627] example.pdf: Rule OCR pdf matched.
2014-02-19 10:51:33.114 hazelworker[63204] Processing folder Skrivebord
2014-02-19 10:51:35.275 hazelworker[63204] Tmp: Rule Old files to temp matched.
2014-02-19 10:51:35.326 hazelworker[63204] Error moving file /Users/mabuse/Desktop/Tmp to /Users/mabuse/Desktop/Tmp/Tmp: -50 - error in user parameter list
2014-02-19 10:51:35.326 hazelworker[63204] [Error] Move failed: Could not move file Tmp from folder /Users/mabuse/Desktop to folder /Users/mabuse/Desktop/Tmp.
2014-02-19 10:51:35.328 hazelworker[63204] Done processing folder Skrivebord
2014-02-19 10:52:21.096 hazelworker[62627] [Error] AppleScript failed: Error executing AppleScript on file /Users/mabuse/Downloads/Example.pdf.
2014-02-19 10:52:21.096 hazelworker[62627] AppleScript error: {
    NSLocalizedDescription = "FineReader got an error: AppleEvent timed out.";
    NSLocalizedFailureReason = "AppleEvent timed out.";
    OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: [0x0,7a27a2 \"FineReader\"]>";
    OSAScriptErrorAppNameKey = FineReader;
    OSAScriptErrorBriefMessageKey = "AppleEvent timed out.";
    OSAScriptErrorMessageKey = "FineReader got an error: AppleEvent timed out.";
    OSAScriptErrorNumberKey = "-1712";
    OSAScriptErrorRangeKey = "NSRange: {0, 0}";
Dr Mabuse
 
Posts: 2
Joined: Tue Feb 18, 2014 9:58 am

It appears the script timed out. I'm guessing it took too long to do the scan? Unfortunately, there's no way to adjust the timeout on Hazel's end. Maybe you can look up some way to hand things off to FineReader and then return immediately so Hazel isn't left waiting?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I know this is an old post. I just wanted it solved, as I faced a similar problem.

I had similar problems using AppleScript to move files that were too big and took many minutes to conclude.

There is an easy solution for this. You need to change the timeout expected for the event just like this simple code:
Code: Select all
with timeout of 300 seconds
 -- code that takes up to 300 seconds
end timeout


Of course you can change it for the amount of time you desire. In my case, I calculated the expected transfer time using file size... but you can use it with any arbitrary number of seconds that you think it will be enough.

Source: http://www.filemaker.com/help/12/fmp/ht ... 13.16.html
gmcouto
 
Posts: 1
Joined: Wed May 13, 2015 3:58 am


Return to Open Discussion