I did a bit of looking around and found a couple more ways to do it.
1. qpdf gives a bit cleaner results.
Code:
for f in *.pdf; do qpdf --show-encryption $f > /dev/null; done
2. For those like me that find perl easier to read and write than python
Code:
#!/usr/bin/perl
use PDF::API2;
while (glob "*.pdf") {
$pdf = PDF::API2->open($_);
print "$_ is encrypted.\n" if $pdf->isEncrypted();
}
PDF::API2 was not included by default on any of my systems, but neither was PyPDF2 including on a very large anaconda install of python at work.