Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried this command but I think something is wrong with '{}' '{}'. By the latter, I want InputXYZ.pdf OutputXYZ.pdf (I do not want any dupe files, I want to replace the old files to make reading a bit more convenient).

$ find . -name "*.pdf" -ok qpdf --password=passMe --decrypt '{}' '{}' \;

If you have better and simpler ideas to handle this kind of repetitive pass-typing probs with other programs, do not hesitate to comment or answer. Actually, my teachers use many different passwords and it is quite mess to read the documents. Perhaps, some file with their passwords and then just the find -cmd testing every possibility?

share|improve this question

You can't make the input file the same as the output file. At best, qpdf will complain and not do anything. At worst it will truncate the output file to zero bytes and then complain that the input file is empty. So use this:

find . -name "*.pdf" -ok qpdf --password=passMe --decrypt '{}' '{}'.decoded.pdf \;

You can go back and remove the dups once you know qpdf didn't trash your files in some unexpected way.

share|improve this answer

Given @Kyle Jones' answer as decrypt_all_files_with(), you could wrap everything in a for-loop,

for pass in $(cat passwords.txt)
  do decrypt_all_files_with($pass)

(but you possibly want to use -exec instead of -ok, as it doesn't ask for confirmation).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.