From 069c88fc45d06cac225b5c756e4280b7835f3757 Mon Sep 17 00:00:00 2001 From: Tristan Smith Date: Fri, 5 Apr 2024 23:57:45 -0400 Subject: [PATCH] Refactor zipremove.py to handle both directories and ZIP files as input --- zipremove.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zipremove.py b/zipremove.py index 48a5764..90eb8d9 100644 --- a/zipremove.py +++ b/zipremove.py @@ -27,8 +27,14 @@ def process_directory(directory_path): if __name__ == "__main__": if len(sys.argv) != 2: - print("Usage: python script.py ") + print("Usage: python script.py ") sys.exit(1) - directory_path = sys.argv[1] - process_directory(directory_path) + path = sys.argv[1] + if os.path.isdir(path): + process_directory(path) + elif os.path.isfile(path) and path.endswith('.zip'): + print(f"Processing {path}") + filter_and_repack_zip(path) + else: + print("The path is not a directory or a ZIP file.")