How to batch password protect PDFs (one or many passwords)
You have a folder of payslips, invoices or statements, and every PDF needs a password before it goes out. Here is how to password-protect many PDFs at once, with one password for all or a different one per file, and what to do with Word and Excel files. For a single PDF, see how to password-protect a PDF on Windows.
qpdf --encrypt with an open password, a separate owner password and --bits=256 (AES-256) on every PDF in a folder, writing new files so your originals stay until you've checked them. Adobe Acrobat Pro (paid) does the same with an Action Wizard action. Office has no batch password feature, so to lock many Word or Excel files at once, encrypt the files with a tool such as Clavis Encrypt (free) or 7-Zip.Password-protecting a PDF vs encrypting the file
- A PDF password uses the PDF format's own encryption. The file stays a .pdf and opens in any current PDF reader with the password. The user password opens the file; the owner password controls permissions such as printing, which qpdf's manual says "may or may not be enforced by any particular reader". The file name stays visible.
- Encrypting the file wraps the whole file, whatever its type. The other person needs the same tool, but it works for any file, and some tools hide the name.
Free: password-protect a folder of PDFs with qpdf
- Download qpdf from its GitHub release page, which qpdf's download page links to. For 64-bit Windows, take the
msvc64zip and unzip it, for example toC:\Tools.qpdf.exeis in thebinfolder; check that$qpdfin the script matches where it is, because Extract All may add a second folder level. The script needs qpdf 11.7.0 or later. - Put the PDFs in one folder. The script writes protected copies to a new folder.
- Change the paths at the top of the script. Save it as
protect-pdfs.ps1and runpowershell -ExecutionPolicy Bypass -File .\protect-pdfs.ps1, because Windows doesn't run saved scripts by default, or paste the whole script into a PowerShell window. Type the password twice. - Open one protected PDF to check the password works, then close the PowerShell window. Only then delete or move the originals.
& {
$ErrorActionPreference = 'Stop'
$qpdf = "C:\Tools\qpdf-12.4.2-msvc64\bin\qpdf.exe"
$docs = [Environment]::GetFolderPath('MyDocuments')
$source = Join-Path $docs "Payslips"
$target = Join-Path $docs "Payslips-protected"
New-Item -ItemType Directory -Force -Path $target | Out-Null
$p1 = Read-Host "Password for every PDF" -AsSecureString
$p2 = Read-Host "Type it again" -AsSecureString
$pw = [System.Net.NetworkCredential]::new('', $p1).Password
if (-not $pw -or $pw -cne [System.Net.NetworkCredential]::new('', $p2).Password) { throw "Empty, or the two don't match." }
if ($pw.Contains('"') -or $pw.EndsWith('\')) { throw 'Please choose a password without " that doesn''t end in \.' }
$owner = [guid]::NewGuid().ToString() # a random owner password
foreach ($f in Get-ChildItem -LiteralPath $source -Filter *.pdf) {
$out = Join-Path $target $f.Name
& $qpdf $f.FullName --encrypt "--user-password=$pw" "--owner-password=$owner" --bits=256 -- $out
if ($LASTEXITCODE -ne 0) { Write-Warning "$($f.Name): qpdf exit code $LASTEXITCODE, check this file"; continue }
& $qpdf --requires-password "--password=$pw" $out
if ($LASTEXITCODE -ne 3) {
Write-Warning "$($f.Name): password check failed, copy removed"
Remove-Item -LiteralPath $out -ErrorAction SilentlyContinue
}
}
"Done. Check one file in $target, then close this window."
}What the parts do, per qpdf's manual:
--user-passwordis the password people type to open the file.--owner-passwordis random, because qpdf treats an empty owner password, or one equal to the user password, as insecure. You don't need it.--bits=256gives AES-256. qpdf calls 40-bit encryption, and 128-bit without AES, insecure, and suggests them only for testing or very old viewers.- Exit code
2means the file wasn't processed;3means warnings, so check that file.--requires-passwordreturns3when the password works.
The & { } around the script makes it stop as a whole when a check fails, even when pasted. It refuses a password containing " or ending in \: Windows PowerShell 5.1 doesn't escape these in arguments it passes to programs (Microsoft's about_Parsing says quotes inside arguments must be escaped by hand), so qpdf could receive a different password. Unaccented letters, numbers and spaces are safest; qpdf handles other characters "in most cases", its manual says.
A different password for each PDF
When each file goes to a different person, give each its own password. This version makes a random 16-character password per file (no I, O, 0 or 1, so they're easy to read out) and prints each one as soon as its file is done. If a file fails, its protected copy is deleted, so no file is left without a recorded password:
& {
$ErrorActionPreference = 'Stop'
$qpdf = "C:\Tools\qpdf-12.4.2-msvc64\bin\qpdf.exe"
$docs = [Environment]::GetFolderPath('MyDocuments')
$source = Join-Path $docs "Payslips"
$target = Join-Path $docs "Payslips-protected"
New-Item -ItemType Directory -Force -Path $target | Out-Null
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
foreach ($f in Get-ChildItem -LiteralPath $source -Filter *.pdf) {
$bytes = New-Object byte[] 16
$rng.GetBytes($bytes)
$pw = -join ($bytes | ForEach-Object { $chars[$_ % 32] })
$out = Join-Path $target $f.Name
& $qpdf $f.FullName --encrypt "--user-password=$pw" "--owner-password=$([guid]::NewGuid())" --bits=256 -- $out
$ok = ($LASTEXITCODE -eq 0)
if ($ok) { & $qpdf --requires-password "--password=$pw" $out; $ok = ($LASTEXITCODE -eq 3) }
if (-not $ok) {
Write-Warning "$($f.Name): not protected, skipped"
Remove-Item -LiteralPath $out -ErrorAction SilentlyContinue
continue
}
Write-Host "$pw $($f.Name)"
}
}Copy the passwords into your password manager and close the window; don't save them next to the PDFs. If clipboard history is on (Windows logo key + V), everything you copy stays there until you restart or clear it in Settings → System → Clipboard. To hand passwords over safely, send each PDF one way, such as email, and its password another, such as a call or text message, never in the same email or the file name. Avoid passwords made from a birth date or ID number: anyone who knows the person can guess them.
Paid: Adobe Acrobat Pro's Action Wizard
Adobe's help for the Acrobat Pro Action Wizard describes actions as multi-step sequences that run on multiple files: you add files or a whole folder under Files to be processed. An action can include the Encrypt step from the Protection tools. Adobe's help says that with Prompt User ticked, the action asks for a password each time it runs; with it cleared, every document gets the same password. Have the action save the protected copies to a different folder, so your originals stay as they are until you've checked them. Acrobat Pro is paid; check Adobe's current help for exact menus.
Many Word or Excel files at once
Microsoft documents one file at a time: in Excel, File → Info → Protect Workbook → Encrypt with Password; in Word, File → Info → Protect Document → Encrypt with Password. Its Office help describes no way to do a folder at once. Excel's VBA has a Password argument for Workbook.SaveAs (up to 15 characters), so a macro you write could loop through workbooks. Single files: password-protecting a Word or Excel file.
The simpler batch route is to encrypt the files themselves: put them in one 7-Zip archive ("strong AES-256 encryption in 7z and ZIP formats"), or encrypt each with Clavis Encrypt.
Where Clavis Encrypt fits
Clavis Encrypt is a free app for Windows 10 and 11 (64-bit) and Linux that encrypts files of any type, PDFs, Word and Excel included, many at once:
- Install Clavis Encrypt and create your vault. Save the recovery key it shows you.
- In File Explorer, select the files, right-click and choose Clavis → Encrypt (on Windows 11, under Show more options; the right-click menu comes with the download from clavisenc.com). In the Microsoft Store version, drag the files onto the Clavis window, choose Encrypt and press Encrypt now.
- Clavis lists the whole batch. Check it and confirm once.
Each file becomes a .enc file with a random name, sealed with AES-256-GCM; the real name is stored inside. The original is overwritten, then deleted (best effort on SSDs). You open them in Clavis, or in any browser at clavisenc.com/open.html with your password; nothing is uploaded. That suits files you keep. To send one, Send with a password (free) makes a locked copy named after the original with a suggested one-time password, which opens in any browser.
With Clavis Premium ($29 once), clavis-cli does the same from a script, using your vault password. Run it in the folder:
clavis-cli encrypt --keep --out "D:\Encrypted" *.pdf--keep keeps the originals and --out writes the encrypted files elsewhere. The command line isn't in the Microsoft Store version. Clavis is closed source and hasn't been independently audited; its file format is public, with an open-source decryptor.
Which option fits
| Option | Cost | Many files at once | Different password per file | The other person needs | File name hidden |
|---|---|---|---|---|---|
| qpdf and PowerShell | Free, open source | Yes, by script | Yes, by script | Any current PDF reader and the password | No |
| Acrobat Pro Action Wizard | Paid | Yes | Not documented by Adobe | Any current PDF reader and the password | No |
| Word or Excel Encrypt with Password | Part of Office | No, one at a time | Yes, one at a time | Word or Excel and the password | No |
| 7-Zip 7z archive | Free | Yes, into one archive | One per archive | 7-Zip or a similar tool | Yes, with Encrypt file names |
| Clavis Encrypt Free | Free | Yes | Your vault password for files you keep; Send with a password suggests a one-time password each time you use it | Clavis, or any browser at clavisenc.com/open.html | Yes, for files you keep |
| clavis-cli (Clavis Premium) | $29 once | Yes, by script | No, your vault password | Clavis, or any browser at clavisenc.com/open.html | Yes |
What can go wrong
- A forgotten password. There is no reset for an AES-256 PDF. Keep the passwords in a password manager.
- Unprotected copies. The originals are still in the source folder, Sent mail and cloud folders. Delete or encrypt them once the protected copies work.
- Weak encryption by accident. Some tools still offer 40-bit encryption, or 128-bit without AES, which qpdf calls insecure. Use 256-bit.
- Passwords in the open. The scripts keep the password out of your typed history, but it is briefly part of qpdf's command line on your PC. qpdf's manual offers
@filename(delete that file afterwards) or@-, which reads arguments from standard input, instead. Close the PowerShell window when you're done. - Trusting restrictions. "No printing" or "no copying" is up to the reader app. Only the open password keeps people out.
Questions
Can I password protect multiple PDF files at once for free?
Yes. Use the free, open-source qpdf in a PowerShell loop that runs qpdf --encrypt with a user password, an owner password and --bits=256 on each PDF in a folder, writing protected copies to a new folder. They open in any current PDF reader with the password.
How do I batch password protect PDFs with different passwords?
Generate a random password for each file inside the loop and pass it to qpdf as the user password, then save the file-and-password list in a password manager.
Can Adobe Acrobat password protect multiple PDFs at once?
Acrobat Pro can, with the Action Wizard: create an action with the Encrypt step and run it on a set of files or a folder. Acrobat Pro is paid.
How do I password protect multiple Excel files at once?
Excel has no built-in batch option; Microsoft documents File, Info, Protect Workbook, Encrypt with Password one file at a time. Write a VBA macro, or encrypt the files at once with a tool such as Clavis Encrypt or an encrypted 7-Zip archive.
Is a password-protected PDF really encrypted?
Yes, if it has an open (user) password: the contents are encrypted, and with 256-bit encryption the method is AES. A PDF with only an owner password opens without any password, so its contents aren't protected. The file name is never hidden.
How should I send the passwords?
Separately from the files: the PDF by email or a link, the password by a phone call or text message. Never in the same email, its subject line or the file name.
Sources
- qpdf manual: Running qpdf (--encrypt, --user-password, --owner-password, --bits=256, insecure options and very old viewers, exit codes, --requires-password, @filename and @-, Unicode passwords)
- qpdf manual: PDF Encryption (user and owner passwords)
- qpdf manual: Downloading qpdf
- qpdf on GitHub: releases (Windows builds, including msvc64)
- qpdf manual: License (Apache License 2.0)
- Microsoft Learn: about_Parsing, Windows PowerShell 5.1 (quote characters in arguments to programs; -- is passed through)
- Microsoft Learn: about_Execution_Policies, Windows PowerShell 5.1 (Restricted by default on Windows clients; -ExecutionPolicy for one session; Bypass)
- Microsoft Support: Using the clipboard (clipboard history, Windows logo key + V, clearing it, cleared at restart)
- Adobe Help: Adobe Acrobat Pro Action Wizard (actions on multiple files, Files to be processed)
- Adobe Help: Set fewer than six characters long password for a PDF (an Action Wizard action with Protection, Encrypt and Prompt User)
- Microsoft Support: Protect an Excel file (Encrypt with Password)
- Microsoft Support: Protect a document with a password (Word)
- Microsoft Learn: Workbook.SaveAs method, Excel VBA (Password, no more than 15 characters)
- 7-Zip home page (AES-256 encryption in 7z and ZIP formats)
Last checked against the qpdf 12.4.2 manual, Microsoft's documentation and Adobe's help on November 15, 2026. Menu names can differ between versions.
Related: encrypting a file with PowerShell, whether Windows Backup is encrypted and hiding a folder in Windows 11.