Embedded Script Error

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

Moderator: Mr_Noodle

Embedded Script Error Mon Sep 11, 2023 6:35 pm • by forts.earners
I have an action with the following shell script which works fine...

Code: Select all
qpdf $1 --decrypt --password=xxxxxxxx --replace-input
ocrmypdf --force-ocr --deskew $1 $1

I decided to split this into two actions, with the first being the qpdf command, but checking for a specific file name...
Code: Select all
if [[ $1 == myEncryptedFile ]]; then
  qpdf $1 --decrypt --password= xxxxxxxx --replace-input
else
  echo "No Match"
fi

I have enabled Hazel debugging and when the action runs it drops inside the if statement, but then fails on the qpdf command. Here is the script output...

2023-09-11 18:12:57.616 hazelworker[80066] DEBUG: == script output ==
EncryptedPdfError: Input PDF is encrypted. The encryption must be removed to
perform OCR.

For information about this PDF's security use
qpdf --show-encryption infilename

You can remove the encryption using
qpdf --decrypt [--password=[password]] infilename

== End script output ==


The files security allows all actions once decrypted. I changed my qpdf format to that provided in the script output, but receive the same output. I am at a loss as I mentioned before. Any help would be appreciated.
Last edited by forts.earners on Fri Sep 15, 2023 2:13 pm, edited 1 time in total.
forts.earners
 
Posts: 3
Joined: Fri Jun 16, 2023 4:24 pm

Re: Embedded Script Error Wed Sep 13, 2023 8:35 am • by Mr_Noodle
I'm unclear on why you are checking for a specific file name. I don't know the programs in questoin. Does qpdf always output using the same filename?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Embedded Script Error Fri Sep 15, 2023 12:27 pm • by forts.earners
Of all the files that I am processing with Hazel, it is just this one file that is encrypted and always has the same name, thus that is what I look for. The program does not always output the same filename, that is just what I asked it to do with the replace-input option.

I actually realized that the output I provided in my initial post is from the second script where it tries to OCR the file. The script where I am attempting to decrypt the file, I found was not dropping into the if statement because I was matching just the filename (sans the extension), and $1 is the full path and filename. I modified the script to the following and it works perfectly.

Code: Select all
fullPath=$1
fileName=$fullPath:t

if [[ $fileName == myEncryptedFile.pdf ]] then
  qpdf $1 --decrypt --password=xxxxxxxx --replace-input
else
  echo "No Match"
  echo $1
  echo $fileName
fi
forts.earners
 
Posts: 3
Joined: Fri Jun 16, 2023 4:24 pm


Return to Support