from PyPDF2 import PdfFileMerger import os path = "/path/to/folder" merged_pdf = "merged.pdf" merger = PdfFileMerger() for filename in os.listdir(path): if filename.endswith(".pdf"): merger.append(os.path.join(path, filename)) merger.write(os.path.join(path, merged_pdf)) merger.close()