From 920bb30e898755c941cb231de6deb125a3038ee0 Mon Sep 17 00:00:00 2001 From: eworc778 Date: Thu, 22 Aug 2024 20:31:45 +0100 Subject: [PATCH] Added logic to number pages. --- main.py | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 31ff52f..281e222 100644 --- a/main.py +++ b/main.py @@ -21,7 +21,7 @@ try: print("Printer URI is:") - printerURI = f.readline() + printerURI = f.readline().replace("\n", "") print(printerURI) except: @@ -85,6 +85,48 @@ def putCommandTogether(pageNumber=int()): #Final command looks like this: hp-scan -d escl:https://192.168.0.XX:443 -o --pg.jpg -mcolor; magick convert --.jpg img.pdf - finalCommand = "hp-scan -d " + printerURI - finalCommand = finalCommand + "-o " + mainCategory + "-" + subCategory + "-pg" + pageNumber + #More Convienient + + documentName = mainCategory + "-" + subCategory + "-pg" + str(pageNumber) + + + + + finalCommand = "hp-scan -d " + printerURI + " " + + + + finalCommand = finalCommand + "-o " + documentName + ".jpg -mcolor; magick convert " + documentName + ".jpg " + documentName + ".pdf" + + return finalCommand + +#Make folders needed + +os.system("mkdir " + mainCategory) + +os.chdir(mainCategory) + +os.system("mkdir " + subCategory) + +os.chdir(subCategory) + +curPage = 0 + +while numberOfPages > curPage: + + finalCommand = putCommandTogether(numberOfPages) + + os.system(finalCommand) + + curPage += 1 + + if curPage != numberOfPages: + + print("Waiting 5 seconds for next page...") + + time.sleep(5) + + #Cleanup + + os.system("rm *.jpg")