Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dedupe

A command-line tool that finds duplicate files in a directory tree and can reclaim the wasted space. It is plain Python with no third-party dependencies.

dedupe in action

How it works

Comparing every file against every other file would be slow, so dedupe is careful about what it reads:

  1. Group files by size. Files of different sizes can never be identical, so most candidates are ruled out for free.
  2. For same-size groups, hash only the first 64 KB. That eliminates the majority of near-matches without reading whole files.
  3. For files that still look alike, compute a full SHA-256 to confirm they are identical byte for byte.

By default it only reports. Deleting takes an explicit --delete flag, and it always keeps one copy of every group.

Usage

# report duplicates under a folder
python3 dedupe.py ~/Downloads

# ignore anything smaller than 1 MB
python3 dedupe.py ~/Downloads --min-size 1048576

# machine-readable output
python3 dedupe.py ~/Downloads --json

# delete duplicates, keeping one of each (asks for confirmation)
python3 dedupe.py ~/Downloads --delete

# delete without the prompt
python3 dedupe.py ~/Downloads --delete --yes

Safety

  • Symlinks are skipped, so it never follows links out of the tree.
  • Deletion keeps the first file in each group and only removes exact, hash-verified duplicates.
  • Without --delete, nothing is ever changed.

Tests

python3 -m unittest

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages