mirror of
https://github.com/kevinveenbirkenbach/duplicate-file-handler.git
synced 2024-11-14 18:11:03 +01:00
implemented multi directory scan
This commit is contained in:
parent
db65668217
commit
73f2bbe409
24
main.py
24
main.py
@ -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> ...")
|
||||||
|
Loading…
Reference in New Issue
Block a user