I have some n number of pdf files which are SECURED( i.e not password secured, but owner secured). I was able to decrypt single pdf at a time using _ "qpdf --decrypt Input.pdf Output.pdf" from Cmd Promt in Windows. can you help me to do the same with multiple pdf's using batch file or from cmd prompt.
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 files
if [ -d output ];
then
echo "output directory exists"
else
mkdir output
fi
yourfilenames=`ls *.pdf`
#echo yourfilenames
for eachfile in $yourfilenames
do
echo $eachfile
qpdf --decrypt $eachfile output/$eachfile
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With