Detect password protected PDFs

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

Moderator: Mr_Noodle

Detect password protected PDFs Wed Feb 12, 2020 4:27 pm • by CONSULitAS
Hi to all,

i tried to detect password protected PDFs with a hazel rule.

The hint in viewtopic.php?t=12289&p=30334 to read the attribute "security" (in german "Sicherheit") does not work:

Tested with an example file the attribute matches "is blank", which is unexpected.

Any help is appreciated.

Thanks in advance
CONSULitAS
 
Posts: 4
Joined: Wed Feb 12, 2020 4:16 pm

Re: Detect password protected PDFs Thu Feb 13, 2020 11:57 am • by Mr_Noodle
If you select the file in Finder and do "Get Info", is there anything under "More Info"?
Mr_Noodle
Site Admin
 
Posts: 8523
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Detect password protected PDFs Sat Feb 15, 2020 11:42 am • by CONSULitAS
Mr_Noodle wrote:If you select the file in Finder and do "Get Info", is there anything under "More Info"?


Thanks for the quick reply.

No, there is only "zuletzt geöffnet" (last opened at). :?
CONSULitAS
 
Posts: 4
Joined: Wed Feb 12, 2020 4:16 pm

Re: Detect password protected PDFs Sat Feb 15, 2020 12:27 pm • by CONSULitAS
PS: Reason for the question is, that any rules checking the content of files crash and lead to an error, if they try to analyze a password protected PDF.

So it seems to be necessary to have a rule that recognizes these PDFs and remove the password or sort them away before other rules start.

Any ideas else?
CONSULitAS
 
Posts: 4
Joined: Wed Feb 12, 2020 4:16 pm

Re: Detect password protected PDFs Sat Feb 15, 2020 2:26 pm • by CONSULitAS
PPS: In theory it is quite simple. Explained here: https://www.mobileread.com/forums/showt ... hp?t=37974

But if you build a rule with
* Kind is PDF (gives true)
* Contents contain "/encrypt" (gives false -> "Could not import text from /Users/...")

So hazel doesn't let you look into the PDF (raw data), because it tries to read the text content in the file, but gives an error doing so.

My suggestion is a new file type for "Kind": "PDF - password encrypted"
CONSULitAS
 
Posts: 4
Joined: Wed Feb 12, 2020 4:16 pm

Re: Detect password protected PDFs Tue Feb 18, 2020 11:57 am • by Mr_Noodle
If there's no data in the More info section, that suggests that Spotlight is not indexing the file. You'll need to diagnose Spotlight on your system to figure out why that is the case. When working properly. I believe the Security field should be available.

I'm not sure if shoehorning this into "Kind" is the appropriate solution for this. It would be better to do your check in a script in a rule condition.
Mr_Noodle
Site Admin
 
Posts: 8523
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Detect password protected PDFs Thu Mar 26, 2020 12:40 pm • by Yak_Forger
So, has any of the offered solutions worked? I'd be glad to know as well, I can handle encrypted .pdfs manually so far, but as I start working with Hazel more and more, I'm afraid to lose too much time on that.
Yak_Forger
 
Posts: 5
Joined: Thu Mar 26, 2020 5:39 am


Return to Support