implemented multi directory scan

This commit is contained in:
Kevin Veen-Birkenbach 2023-11-14 10:33:49 +01:00
parent db65668217
commit 73f2bbe409

24
main.py
View File

@ -45,20 +45,24 @@ def handle_duplicates(duplicates):
[print(duplicate) for duplicate in files if duplicate != file] [print(duplicate) for duplicate in files if duplicate != file]
delete_file(file) delete_file(file)
def main(directory): def main(directories):
if not directory: all_duplicates = defaultdict(list)
print("Directory path not provided") for directory in directories:
return if not os.path.isdir(directory):
print(f"Directory not found: {directory}")
duplicates = find_duplicates(directory) continue
if not duplicates: duplicates = find_duplicates(directory)
for hash, files in duplicates.items():
all_duplicates[hash].extend(files)
if not all_duplicates:
print("No duplicates found.") print("No duplicates found.")
return return
handle_duplicates(duplicates) handle_duplicates(all_duplicates)
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) > 1: if len(sys.argv) > 1:
main(sys.argv[1]) main(sys.argv[1:])
else: else:
print("Usage: python3 script.py <directory>") print("Usage: python3 script.py <directory1> <directory2> ...")