Advertisement
yclee126

merge PDF files

Nov 16th, 2021
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. import os
  2. from PyPDF2 import PdfFileMerger
  3.  
  4. x = [a for a in os.listdir() if a.endswith(".pdf")]
  5. x.sort()
  6.  
  7. merger = PdfFileMerger()
  8.  
  9. for pdf in x:
  10. merger.append(open(pdf, 'rb'))
  11.  
  12. name = x[-1]
  13. from pathlib import Path
  14.  
  15. name = Path(name).resolve().stem
  16.  
  17. with open(name + '까지.pdf', "wb") as fout:
  18. merger.write(fout)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement