From cce186b0e9d4dbe8e929fbf933ed093088eb1214 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Wed, 26 Feb 2020 05:57:50 +0100 Subject: Added file overwrite warning --- filmstripper.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/filmstripper.py b/filmstripper.py index 52fa682..76db78e 100644 --- a/filmstripper.py +++ b/filmstripper.py @@ -1,6 +1,8 @@ from PIL import Image import glob import sys +import random +from os import path broke = False @@ -33,6 +35,19 @@ except: print("ERROR: Output file argument invalid.") broke = True +if path.isfile(outputFile): + print("Output file already exists. What would you like to do? Overwrite, Cancel or Unique?") + answer = input("[O/C/U]: ") + if answer == "O" or answer == "o": + None + elif answer == "C" or answer == "c": + broke = True + elif answer == "U" or answer == "u": + index = outputFile.find(".") + newName = outputFile[:index] + str(random.randint(1000, 9999)) + outputFile[index:] + print("New output filename: "+newName) + outputFile = newName + brkck() try: -- cgit v1.2.1