Problem with embedded Apple Script / tags

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Problem with embedded Apple Script / tags Sun Oct 16, 2016 9:22 am • by deathlord
Ok, I am trying to optimize my pdf processing for encrypted pdfs. Currently I have multiple rules for sorting documents into folders. If no rule matches (and the file does not contain the "ocr" tag) the files is run through OCR with PDFPen Pro with an embedded applescript and adding the "ocr" tag at the end of the rule.
Code: Select all
tell application "PDFpenPro"
   delay 5
   open theFile as alias
   tell document 1
      ocr
      repeat while performing ocr
         delay 1
      end repeat
      delay 1
      close with saving
   end tell
end tell


This works fine unless I get an encrypted pdf. In that case the applescript fails but the "ocr" tag still gets added to the file. So what I want to do is, that if the OCR of the file fails, I want to run the file through a decryption rule with PDFKey Pro.

So first idea was to include the tag into the script instead of just adding it as second action of the hazel rule, but I couldn't figure out how to add the "orc" tag inside the apple script.
Code: Select all
   tell application "Finder"
      delay 5
      set tags of theFile to item "ocr"
   end tell
I found no way to access the (custom) ocr tag, and all sample scripts I found referred to the standard colored tags. Regardless of that, based on the console output I suspect that the script would have continued and added the tag regardless of the OCR failure.

Is there a way to tell hazel to stop with the current rule and proceed with the next one, or alternatively to add a tag if the rule/script fails? Or could anyone expand the embedded applescript to just add the "ocr" tag after successful completion of the OCR part?
deathlord
 
Posts: 4
Joined: Wed Sep 21, 2016 2:11 pm

Re: Problem with embedded Apple Script / tags Mon Oct 17, 2016 11:00 am • by Mr_Noodle
Can you incorporate the PDFKey Pro part into your script so that you don't have to set the intermediate tag?
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support