I used this code to do the same. It uses Python (2.7 not Python 3) and the reportlab package, downloaded from here http://www.reportlab.com/software/installation/ , and iterates over all the subdirectories of what you set as βrootβ and creates one PDF of all jpeg in each folder.
import os from reportlab.pdfgen import canvas from reportlab.lib.utils import ImageReader root = "C:\\Users\\Harry\\" try: n = 0 for dirpath, dirnames, filenames in os.walk(root): PdfOutputFileName = os.path.basename(dirpath) + ".pdf" c = canvas.Canvas(PdfOutputFileName) if n > 0 : for filename in filenames: LowerCaseFileName = filename.lower() if LowerCaseFileName.endswith(".jpg"): print(filename) filepath = os.path.join(dirpath, filename) print(filepath) im = ImageReader(filepath) imagesize = im.getSize() c.setPageSize(imagesize) c.drawImage(filepath,0,0) c.showPage() c.save() n = n + 1 print "PDF of Image directory created" + PdfOutputFileName except: print "Failed creating PDF"
Harry spier
source share