Created
February 1, 2023 12:14
-
-
Save icecore2/b88c098b19d6cc553ec7aca20f1293f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pikepdf | |
import os | |
import pathlib | |
pdf_pass = 'PASSWORD' | |
pdf_path = '' | |
if not pdf_path: | |
curr_path = pathlib.Path(__file__).parent.absolute() | |
save_localtion = fr"{curr_path}\passwordless" | |
for root, dirs, files in os.walk(curr_path, topdown=True): | |
for name in files: | |
print(os.path.join(root, name)) | |
name = name.lower() | |
if name.endswith(".pdf"): | |
try: | |
with pikepdf.open(os.path.join(curr_path, name), password=pdf_pass) as pdf: | |
print("\nProcessing...\n") | |
pdf.save(os.path.join(save_localtion, name)) | |
print("The password successfully removed from the PDF") | |
print(f"\aLocation: '{save_localtion}'") | |
except Exception as e: | |
print(e) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment