(root, password)
Decrypts all pdfs folder walk
       Args:
          root (str): folder path to walk
          password (str): password to decrypt pdfs with
       Returns:
          None
Decrypts all pdfs folder walk
       Args:
          root (str): folder path to walk
          password (str): password to decrypt pdfs with
       Returns:
          None
Decrypts all pdfs folder walk Args : root ( str ) : folder path to walk password ( str ) : password to decrypt pdfs with Returns : None
def decryptPDFs(root, password):
    """Decrypts all pdfs folder walk
       Args:
          root (str): folder path to walk
          password (str): password to decrypt pdfs with
       Returns:
          None
    """
    for folder, subfolder, fileList in os.walk(root):
        for file in fileList:
            if file.endswith('_encrypted.pdf'):
                filepath = os.path.join(os.path.abspath(folder), file)
                pdfFileObj = open(filepath, 'rb')
                pdfReader = PyPDF2.PdfFileReader(pdfFileObj)

                if pdfReader.isEncrypted:
                    success = pdfReader.decrypt(password)
                    
                    if success:
                        pdfWriter = PyPDF2.PdfFileWriter()
                        for pageNum in range(pdfReader.numPages):
                            pdfWriter.addPage(pdfReader.getPage(pageNum))
                        newPath = os.path.dirname(filepath) + '/' + \
                                ''.join(os.path.basename(filepath).split('_encrypted'))
                        resultPdf = open(newPath, 'wb')
                        pdfWriter.write(resultPdf)
                        resultPdf.close()
                    else:
                        print('wrong password provided')
def decryptPDFs ( root , password ) : for folder , subfolder , fileList in os . walk ( root ) : for file in fileList : if file . endswith ( '_encrypted.pdf' ) : filepath = os . path . join ( os . path . abspath ( folder ) , file ) pdfFileObj = open ( filepath , 'rb' ) pdfReader = PyPDF2 . PdfFileReader ( pdfFileObj ) if pdfReader . isEncrypted : success = pdfReader . decrypt ( password ) if success : pdfWriter = PyPDF2 . PdfFileWriter ( ) for pageNum in range ( pdfReader . numPages ) : pdfWriter . addPage ( pdfReader . getPage ( pageNum ) ) newPath = os . path . dirname ( filepath ) + '/' + '' . join ( os . path . basename ( filepath ) . split ( '_encrypted' ) ) resultPdf = open ( newPath , 'wb' ) pdfWriter . write ( resultPdf ) resultPdf . close ( ) else : print ( 'wrong password provided' )