Problem with embedded Apple Script / tags

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.
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.
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?
- 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
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?