User Tools

Site Tools


doc:appunti:linux:sa:offlineimap3_nametrans

This is an old revision of the document!


offlineimap3 IMAP syncronization: nametrans

#!/usr/bin/env python3
import re
 
# From IMAP to Maildir:
# Add a leading '.' to the folder name.
# Remove the leading INBOX folder name.
# Move the top-level folders into the INOBOX.
# Replace the '.' character with the '_' in folder names.
nametrans = lambda foldername: re.sub(
        r'^\.INBOX$', '',
        '.' + re.sub(
            r'^INBOX/', '',
            foldername.replace('.', '_')
        )
)
 
dirs = [
    'INBOX',
    'INBOX/XFER NETWORK',
    'INBOX/general management',
    'Archives',
    'Archives/2013',
    'INBOX/M.T.T.',
    'INBOX/NEW OFFICES '
]
 
for name in dirs:
    print('%-30s => "%s"' % ('"' + name + '"', nametrans(name)))
doc/appunti/linux/sa/offlineimap3_nametrans.1711100448.txt.gz · Last modified: 2024/03/22 10:40 by niccolo