PDF Encryption Using Python
<p>The code below takes in a single pdf file and then encrypts it, What i want it to do is to take a directory containing pdf files and encrypt the files in that directory automatically, instead of specifying each file explicitly. Please help ! </p>

<pre><code>def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-i', '--input_pdf', required=True,
                        help='Input pdf file')
    parser.add_argument('-p', '--user_password', required=True,
                        help='output CSV file')
    parser.add_argument('-o', '--owner_password', default=None,
                        help='Owner Password')
    args = parser.parse_args()
    set_password(args.input_pdf, args.user_password, args.owner_password)

if __name__ == "__main__":
    main()
</code></pre>

<pre><code>import glob
import os

os.chdir('/some/directory/that/has/pdfs')
for file in glob.glob('*.pdf'):
    set_password(file, upass, opass)
</code></pre>

python python-2.7