philiprehberger-duplicate-finder
Content-hash duplicate file detection with two-pass efficiency.
Installation
pip install philiprehberger-duplicate-finder
Usage
Finding Duplicates
from philiprehberger_duplicate_finder import find_duplicates
# Find duplicates in a directory
groups = find_duplicates("~/Documents")
for group in groups:
print(f"Size: {group.size} bytes, {group.count} copies, wasted: {group.wasted_bytes} bytes")
for path in group.paths:
print(f" {path}")
Filtering Options
# Multiple directories with filters
groups = find_duplicates(
paths=["~/Documents", "~/Downloads"],
min_size=1024,
extensions=[".pdf", ".jpg", ".png"],
algorithm="sha256",
)
# Progress tracking
groups = find_duplicates(
"~/Pictures",
on_progress=lambda current, total: print(f"{current}/{total}"),
)
Smart Keep/Delete Suggestions
for group in groups:
# Keep the most recently modified file
keep = group.keep_newest()
print(f"Keep: {keep}")
# Or keep the file with the shortest path (shallowest)
keep = group.keep_shortest_path()
print(f"Keep: {keep}")
# Get the list of files safe to delete
to_delete = group.deletable(strategy="newest")
for path in to_delete:
print(f" Delete: {path}")
API
| Function / Class | Description |
|---|---|
find_duplicates(paths, ...) |
Find duplicate files using a two-pass size-then-hash approach |
DuplicateGroup |
A group of duplicate files with paths, size, hash, count, and wasted_bytes |
DuplicateGroup.keep_newest() |
Return the path with the most recent modification time |
DuplicateGroup.keep_shortest_path() |
Return the path with the shortest string length |
DuplicateGroup.deletable(strategy) |
Return all paths except the one to keep ("newest" or "shortest_path") |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Release files for philiprehberger-duplicate-finder 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| philiprehberger_duplicate_finder-0.3.1.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| philiprehberger_duplicate_finder-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / philiprehberger_duplicate_finder-0.3.1.tar.gz
| Download URL | philiprehberger_duplicate_finder-0.3.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db39d710e49a6ee50af32cc08ddb858689f196e076ac9f7b50d4dc8b4169cdc7
|
|
BLAKE2b-256 checksum How to use checksums |
213d9896f5900fab67f2c1b496fbb1c1e46880b992f2770b34d43cf9ca5a29c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / philiprehberger_duplicate_finder-0.3.1-py3-none-any.whl
| Download URL | philiprehberger_duplicate_finder-0.3.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8103597f4b7868a230beac3f4c053e5bacafd90da89ab4db076da37e5ddb842f
|
|
BLAKE2b-256 checksum How to use checksums |
1492968dbc035649c929d28401e6d165fc3a095161a130ca17d2ead57e5a4395
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|