Created
August 10, 2022 12:26
-
-
Save Burekasim/cb9686195ebd4e047f62b835770a5d40 to your computer and use it in GitHub Desktop.
Pdf merger (Regina 2000)
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 datetime | |
from PyPDF2 import PdfFileMerger | |
import os | |
def get_pdf_files_from_current_folder(current_folder: str): | |
output_list = [] | |
for item in os.listdir(current_folder): | |
if item.endswith('.pdf'): | |
output_list.append(item) | |
return sorted(output_list) | |
if __name__ == '__main__': | |
folder = os.getcwd() | |
pdfs = get_pdf_files_from_current_folder(folder) | |
os.chdir(folder) | |
merger = PdfFileMerger() | |
for pdf in pdfs: | |
merger.append(pdf) | |
current_time = datetime.datetime.now().strftime('%H%M%S') | |
merger.write(f'{current_time}-regina2000.pdf') | |
merger.close() |
I've updated the repo with natural sort instead of the sorted function.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And now there is a repository
https://github.com/Burekasim/Regina2000-pdf-merger