Created
April 2, 2011 22:36
-
-
Save jcrobak/899970 to your computer and use it in GitHub Desktop.
Makes a mbox from all the files in the directory -- for example, used for recovering files in Mail.app's .OfflineCache.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mailbox | |
import email.utils | |
import os | |
mbox = mailbox.mbox('recovered.mbox') | |
mbox.lock() | |
try: | |
for infile in os.listdir(os.path.dirname(os.path.abspath(__file__))): | |
if not '.' in infile: | |
print "processing: %s" % infile | |
fp = open(infile) | |
msg = email.message_from_file(fp) | |
fp.close() | |
mbox.add(msg) | |
mbox.flush() | |
finally: | |
mbox.unlock() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment