Skip to content

Instantly share code, notes, and snippets.

@lewisthompson
lewisthompson / dedupe_maildir.sh
Last active July 28, 2022 09:05
Dedupe a Maildir with X-TUID headers
#!/usr/bin/env bash
set -euo pipefail
# After some strange combination of OfflineIMAP & mbsync/isync created a whole
# bunch of duplicate messages in my Fastmail account I had to start cleaning things
# up. I discovered that the duplicates all had X-TUID headers and were showing up
# totally out of order in the Fastmail UI. I now run mbsync with `CopyArrivalDate yes`
# which appears prevents this from occurring again.
#
# I found that every message with an X-TUID header had a matching message without
@lewisthompson
lewisthompson / dedupe_maildir.py
Created January 19, 2019 19:59
Part of dedupe_maildir.sh
#!/usr/bin/env python
import sys
tuids = {}
xtuids_filename = sys.argv[1]
dupes1_filename = sys.argv[2]
dupes_filename = sys.argv[3]
origs_filename = sys.argv[4]