Skip to content

Instantly share code, notes, and snippets.

@nuxwin
Forked from greencm/mbox-count.py
Created May 28, 2017 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuxwin/095cf07576848e76426f66017ec6b700 to your computer and use it in GitHub Desktop.
Save nuxwin/095cf07576848e76426f66017ec6b700 to your computer and use it in GitHub Desktop.
Count the number of messages in an mbox file
#!/usr/bin/env python
# $Id$
# Author: <cmgreen@uab.edu>
# Purpose: Count the number of mails in an mbox file
# Created: Fri Jun 28 10:39:13 CDT 2013
import sys
from mailbox import mbox
import re
def count_mbox(box):
i = 0
for n, msg in box.iteritems():
i+=1
return i
if __name__=='__main__':
for f in sys.argv[1:]:
print f, count_mbox(mbox(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment