diff --git a/System-Automation-Scripts/qrGenerator/README.md b/System-Automation-Scripts/qrGenerator/README.md new file mode 100644 index 00000000..11f28139 --- /dev/null +++ b/System-Automation-Scripts/qrGenerator/README.md @@ -0,0 +1,5 @@ +# qrGenerator + +- A Python Script that asks the user to input an URL or any string of characters and then coverts it to a QR code as the name of the URL domain, saved locally in the current working directory or as specified by the user. +- Also, if the program finds an existing QR with the same filename, it creates a new one with a random number at the end of the filename. +- Can be used either in the Command Line or within the Python IDE diff --git a/System-Automation-Scripts/qrGenerator/qrGenerator.py b/System-Automation-Scripts/qrGenerator/qrGenerator.py new file mode 100644 index 00000000..65fd4728 --- /dev/null +++ b/System-Automation-Scripts/qrGenerator/qrGenerator.py @@ -0,0 +1,20 @@ +import os +import qrcode +from sys import argv +from urllib.parse import urlparse +import random + +if len(argv)==2: + url = str(argv[1]) +else: + url = input("Enter an URL to Encode in QR: ") + +path = ((urlparse(url)).netloc) +image = qrcode.make(url) + +if os.path.exists(f"{path}.png"): + path = path + str(random.randint(0,10000)) + +image.save(f"{path}.png", "PNG") +file_path = os.path.abspath(path) +print("File saved to:", file_path) \ No newline at end of file