Compare commits

...

4 Commits

Author SHA1 Message Date
326577e5ca
feat(arg): add directory argument
Add an argument which allows the user to specify which directory should
be scanned for duplicates, rather than hard-code the directory into the
script. This makes the script portable and easier-to-use.
2025-06-25 21:48:13 +00:00
86d6740302
feat(arg): add dry-run argument
Add a dry-run argument so the user can have the script detect duplicates
without deleting them. This is useful for informing the user of which
files would be deleted, should they run the script, normally.
2025-06-25 21:46:03 +00:00
4c6112f0a7
feat(arg): add parser description 2025-06-25 21:45:09 +00:00
448c572026
feat(lib): import library "argparse" 2025-06-25 21:43:39 +00:00

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
# Duplicate Check
# Version: 0.9.0
# Version: 0.13.0
# Copyright 2025 Jake Winters
# SPDX-License-Identifier: BSD-3-Clause
@ -9,6 +9,12 @@
import os
import hashlib
import argparse
parser = argparse.ArgumentParser(description='Scan directory for duplicate files and delete them.')
parser.add_argument('--dry-run', '-d', action='store_true', help='Detect duplicates without deletion.')
parser.add_argument('directory', type=str, help='The directory to scan for duplicate files.')
def hash_file(file_path):
@ -16,4 +22,4 @@ def hash_file(file_path):
with open(file_path, 'rb') as f:
for byte_block in iter(lambda: f.read(65536), b''):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()
return sha256_hash.hexdigest()