问题
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.
回答1:
@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
)
回答2:
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"
回答3:
Try this: Place all the pdfs in one folder and navigate with cmd prompt to that folder. Execute the following commands:
mkdir output
qpdf --decrypt *.pdf output/*.pdf
回答4:
#!/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
来源:https://stackoverflow.com/questions/24865475/how-to-decrypt-multiple-pdf-files-using-qpdf