Refactor zipremove.py to handle both directories and ZIP files as input

This commit is contained in:
Tristan Smith 2024-04-05 23:57:45 -04:00
parent 7004c40071
commit 069c88fc45

View file

@ -27,8 +27,14 @@ def process_directory(directory_path):
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <directory_path>")
print("Usage: python script.py <path_to_directory_or_zip>")
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.")