Skip to content

Instantly share code, notes, and snippets.

@tajo
Created June 17, 2014 22:50
Show Gist options
  • Save tajo/5cb5ee8ee94aaae38af3 to your computer and use it in GitHub Desktop.
Save tajo/5cb5ee8ee94aaae38af3 to your computer and use it in GitHub Desktop.
MergeEdux
#!/usr/bin/python
import os
from PyPDF2 import PdfFileMerger, PdfFileReader
subs = ['BI-AAG','BI-APS','BI-BEZ','BI-CAO','BI-DBS','BI-EFA','BI-EIA','BI-GRA','BI-LIN','BI-MLO','BI-OSY','BI-PA1','BI-PA2','BI-PJP','BI-PSI','BI-PST','BI-SAP','BI-SI1','BI-VZD','BI-ZDM','BI-ZMA']
folder = "okruhy"
# traverse root directory, and list directories as dirs and files as files
for sub in subs:
for root, dirs, files in os.walk(folder + "/" + sub):
merger = PdfFileMerger()
for pdfko in files:
if pdfko[-3:] == 'pdf':
merger.append(PdfFileReader(file(folder + "/" + sub + "/" + pdfko, 'rb')))
print pdfko
merger.write(folder + "/" + sub + "/" + sub + "_all.pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment