From 0f0d5dfbbdef2ea5a7b37fefeb61dbf0c5838eb4 Mon Sep 17 00:00:00 2001 From: Dazed Date: Wed, 5 Apr 2023 16:48:43 -0500 Subject: [PATCH] feat: Add option to delete files folder contents --- main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.py b/main.py index a9a8f76..61baf2d 100644 --- a/main.py +++ b/main.py @@ -21,6 +21,16 @@ def main(): for filename in os.listdir("files"): if filename.endswith('json'): executor.submit(handle, filename) + + choice = input('Do you want to delete JSON in /files? (y/n) ') + if choice == 'y': + deleteFolderFiles('files') + +def deleteFolderFiles(folderPath): + for filename in os.listdir(folderPath): + file_path = os.path.join(folderPath, filename) + if file_path.endswith('.json'): + os.remove(file_path) def handle(filename): with open('translated/' + filename, 'w', encoding='UTF-8') as outFile: