How to decrypt multiple pdf files using qpdf? How to decrypt multiple pdf files using qpdf? powershell powershell

How to decrypt multiple pdf files using qpdf?


If you just want to run the command from the shell (cmd.exe), you can do something like this from the directory containing the PDFs:

for %a in ("*.pdf") do "c:\Programs\qpdf\bin\qpdf.exe" --decrypt "%a" "%~dpna.decrypted.pdf"


@echo off    setlocal enableextensions disabledelayedexpansion    if not exist output\ md output    for %%a in (*.pdf) do qpdf --decrypt "%%~fa" "output\%%~nxa"

Create an output folder under current directory. Then for each pdf in current folder call qpdf to decrypt, passing as argument the full path of the input file (%%~fa) and the output file, that is, the output folder followed by the name and extension of the file being processed (%%~nxa)


#!/bin/bash# unprotect multiple pdf files in a directory with qpdf 10Jan20# run the script from the same directory as the filesif [ -d output ];then    echo "output directory exists"else    mkdir outputfiyourfilenames=`ls *.pdf`#echo yourfilenamesfor eachfile in $yourfilenamesdo   echo $eachfile    qpdf --decrypt $eachfile    output/$eachfiledone