Hello, I am an Engineering Manager at Facebook with 13+ years in Ad Technology, Natural Language Processing and Data mining. (Learn More)
by Pravin Paratey

Exporting Opera email to mbox format

The following snippet combines the various opera mbs into one mbox format which can be used by other email clients like Evolution to import mail.

#!/usr/bin/python
# Quick hack to merge all opera mbs files into mbox format which can
# then be used by other email clients to import Opera email.
# by Pravin Paratey (January 19, 2009)

import os

# Change this value
folder = '/home/pravin/.opera/mail/store/account1/'

fp = open('combined.mbox', 'a')

for d0 in os.listdir(folder):
	p0 = os.path.join(folder,d0)
	if os.path.isfile(p0): continue
	for d1 in os.listdir(p0):
		p1 = os.path.join(p0, d1)
		for d2 in os.listdir(p1):
			p2 = os.path.join(p1, d2)
			for f in os.listdir(p2):
				fp2 = open(os.path.join(p2, f), 'r')
				fp.write(fp2.read())
				fp2.close()
fp.close()