This is an exemplary duplicate of this Ubuntu question.

I have a number of PDF files that have been sent to me encrypted with a password, which happens to be the same for all PDFs for simplicity. I have no reason to keep the password when I store those files in my permanent archives, nor to type it every time I open those files.

I could use the linked Q&A to build a Docker-based solution to strip the password from the pdf files, or I could ask here if the same is possible with Windows 10.

I have access to choco if I need some packages.

  • qpdf has a Windows executable. You would just need to write the batch equivalent of the bash script in the linked answer. – Worthwelle Dec 4 '19 at 15:44

I think I did it.

Step one: use qpdf.

As a choco user

choco install qpdf

Secondly, use the following PowerShell one-liner (I couldn't parallelize it because PS gave me an error). Takes a few seconds per file

$password = [THE_PASSWORD]
Get-ChildItem | ForEach-Object { qpdf --decrypt --replace-input --password=$password $_.Name}

I was extremely confident running the script wild into production because I had a strong backup, and I had to restore it a couple of times.

Everyone around has suggested to make a backup before running live.

qpdf won't do anything if the file is not encrypted.

I will amend the question accordingly, but the script assumes the password is the same for all files


I struggled with the script but ran this instead from a command prompt in Windows 10 (CMD.EXE):

FOR %G IN (*.pdf) DO qpdf --decrypt --password=mypassword "%G" --replace-input

(Obviously, replace mypassword with the actual password)

The --replace-input avoids the need to specify output filenames, and the use of the FOR command simply cycles through an entire folder of PDFs and removes the encryption.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.