Skip to content

Instantly share code, notes, and snippets.

@jyunderwood
Last active August 29, 2015 14:23
Show Gist options
  • Save jyunderwood/43005102b81ec9036198 to your computer and use it in GitHub Desktop.
Save jyunderwood/43005102b81ec9036198 to your computer and use it in GitHub Desktop.
mboxdiff.py
import mailbox
# Open the mbox files (relative to your present working directory)
# Note, Mail.app actually exports a mbox folder that contains an mbox file
mbox1 = mailbox.mbox('Old-Archive.mbox/mbox')
mbox2 = mailbox.mbox('New-Archive.mbox/mbox')
# Use something like `subject` to unique the messages
# or they will all be unique.
def subjects(mbox):
subjects = []
for message in mbox:
subjects.append(message['subject'])
return subjects
old_subjects = subjects(mbox1)
new_subjects = subjects(mbox2)
# Throw away dups within a mailbox
# and remove all `new_subjects` from the `old_subjects` set
diff = list(set(old_subjects) - set(new_subjects))
# Just the unsynced subjects are left
for subject in diff:
print subject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment