Skip to main content

philiprehberger-duplicate-finder

Tests PyPI version Last updated

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:

⭐ Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Metadata

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)

Source distribution for philiprehberger-duplicate-finder 0.3.1
File Size Uploaded Provenance Actions
philiprehberger_duplicate_finder-0.3.1.tar.gz 6.4 kB Without provenance Details for philiprehberger_duplicate_finder-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for philiprehberger-duplicate-finder 0.3.1
File Interpreter ABI Platform Actions
philiprehberger_duplicate_finder-0.3.1-py3-none-any.whl Python 3 none any Details for philiprehberger_duplicate_finder-0.3.1-py3-none-any.whl

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

Security for philiprehberger-duplicate-finder 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page