Deduplicate mails from a set of maildir folders
Project description
Maildir Deduplicate
Command-line tool to deduplicate mails from a set of maildir folders.
Usage
Usage: __init__.py [OPTIONS] [MAILDIR [MAILDIR ...]]
Detect/remove duplicates from maildir folders
Options:
-h, --help show this help message and exit
-d, --remove-smaller Remove all but largest duplicate in each duplicate set
-r REGEXP, --remove-matching=REGEXP
Remove duplicates whose file path matches REGEXP
-R REGEXP, --remove-not-matching=REGEXP
Remove duplicates whose file path does not match
REGEXP
-o, --remove-older Remove all but the newest duplicate (determined by
ctime) in each duplicate set
-O, --remove-newer Remove all but the oldest duplicate (determined by
ctime) in each duplicate set
-n, --dry-run Don't actually remove anything; just show what would
be removed.
-s, --show-diffs Show diffs between duplicates even if they're within
the thresholds
-i, --message-id Use Message-ID header as hash key (not recommended -
the default is to compute a digest of the whole header
with selected headers removed)
-S BYTES, --size-threshold=BYTES
Specify maximum allowed difference between size of
duplicates. Default is 512; set -1 for no threshold.
-D BYTES, --diff-threshold=BYTES
Specify maximum allowed size of unified diff between
duplicates. Default is 768; set -1 for no threshold.
-H, --hash-pipe Take a single mail message texted piped from STDIN and
show its canonicalised form and hash thereof. This is
useful for debugging why two messages don't have the
same hash when you expect them to (or vice-versa).
Details
This script reads all mails in a given list of maildir folders and subfolders, then automatically detects, lists, and optionally deletes any duplicate mails.
Duplicate detection is done by cherry-picking certain headers, in some cases doing some minor tweaking of the values to reduce them to a canonical form, and then computing a digest of those headers concatenated together.
Note that we deliberately limit this to certain headers due to the effects that mailing list software can have on not only the mail header but the body; it can potentially:
append a footer to a list body, thus changing the Content-Length header;
create a new path described by the Received headers which would not be contained in any copy of the mail saved locally at the time it was sent to the list;
munge the Reply-To header even though it’s a bad idea;
add plenty of other random headers which a copy saved locally at sending-time would not have, such as X-Mailman-Version, Precedence, X-BeenThere, List-*, Sender, Errors-To, and so on;
add a prefix to the Subject header.
Another difficulty is the lack of guarantee that Message-ID is unique or even present. Yes, certain broken mail servers which must remain nameless are guilty of this :-(
For added protection against accidentally removing mails due to false positives, duplicates are verified by comparing body sizes and also diff’ing the contents. If the sizes or contents differ by more than a threshold, they are not counted as duplicates.
So far, it was tested on:
MacOS X 10.6 with Python 2.6.2,
Linux with Python 2.6.0 and 2.7.2.
Contributors
History
This script was initially released in 2010, and was living in a messy GitHub repository. After some years, the script basically outgrew its initial intent, and moved in 2013 to its own repository.
License
This software is licensed under the GNU General Public License v2 or later (GPLv2+).
ChangeLog
0.1.0 (2014-12-15)
Package the script for proper distribution.
0.0.1 (2011-04-27)
First external contribution.
0.0.0 (2010-06-08)
First commit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file maildir-deduplicate-0.1.0.tar.gz
.
File metadata
- Download URL: maildir-deduplicate-0.1.0.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3ba4baa9df47ccef8863e0e482becc47443c3b44c9ccd8ae437d756f8bf134b |
|
MD5 | 2aa329a37d8e46db9893a29b3b227f23 |
|
BLAKE2b-256 | b9189f825de7cb56a9b89e1092afcc9537aa91f33c08e10e320b95cb286813db |
File details
Details for the file maildir_deduplicate-0.1.0-py2.7.egg
.
File metadata
- Download URL: maildir_deduplicate-0.1.0-py2.7.egg
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76bb03f39af10fe27141e88c9ecd35028b98338863c336939df0b6a1fcfedd94 |
|
MD5 | 8c73f156f0f329dc81a52a92b0a7ebe9 |
|
BLAKE2b-256 | 7b85b5dfea370eab545442abdab51a521929f7671d0f928d88167ef1b89aa762 |
File details
Details for the file maildir_deduplicate-0.1.0-py2-none-any.whl
.
File metadata
- Download URL: maildir_deduplicate-0.1.0-py2-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c89fe7b35453681f2ba3f8ac1d7bc67422a34886161dccb0329d118bb557503c |
|
MD5 | b3b9d9a4550c9c711a99fbd19d5dff0d |
|
BLAKE2b-256 | ef4776d532b9b2c826203a2106ac7a44a5d2277759753a53f8ff00fe8f40ffdd |