1

I have a bunch of pdf files and its password in another file, I need to find a way to remove password protection and create a unencrypted pdf file, with the same file name. What would be a best possible way to do it.

Something like, read each pdf file, apply the list of the password to it, on successful removal of the password, rewrite the file into a unencrypted pdf with the same name.

pdfcrack can read the list of passwords, but I don't have the info how to rewrite into a unencrypted pdf file

thanks

1 Answers1

1
#!/bin/bash

filename="password.txt"

#While loop to read line by line

while read -r line
do
    readLine=$line
    for file in *.pdf
    do 
        pan="${line:0:10}"
        /usr/bin/qpdf --password=$line --decrypt $file ack/2017-$pan.pdf

    done
done < "$filename"
nobody
  • 4,362