I am trying to batch-encrypt a set of PDFs using qpdf. This works fine in a shell for loop:
for f in *.pdf; do
qpdf --encrypt "" "" 256 --print=none --modify=none --extract=n -- "$f" "locked/$f"
done
But when I try to parallelize it with GNU Parallel:
parallel -j$(nproc) qpdf --encrypt "" "" 256 --print=none --modify=none --extract=n -- "{}" "locked/{/}" ::: *.pdf
I get the following error:
qpdf: unrecognized argument --print=none (encryption options must be terminated with --)
Why does the exact same qpdf command work in a for loop but not in parallel? How can I fix the GNU Parallel syntax so it runs correctly on all PDFs?
qpdf --version → 10.6.3
The docs are a little confusing but this command works with the current version of qpdf:
parallel -j$(nproc) qpdf --encrypt --bits=256 --print=none --modify=none --extract=n -- "{}" "locked/{/}" ::: *.pdf
Ole Tange, the author of GNU parallel, has provided a canonical solution (+1), but another potential alternative that works with version 10.6.3 is:
parallel -j$(nproc) qpdf --encrypt \"\" \"\" 256 --print=none --modify=none --extract=n -- "{}" "locked/{/}" ::: *.pdf