#!/usr/bin/env python # Scan my maildirs directory (which contains all my mail folders), and create # appropriate symlinks for Gnus. I run this periodically from cron; if I decide # that I don't want Gnus to see a folder, I mv the symlink from .nnmaildir to # .nnmaildir-not. import os home = os.environ["HOME"] yesdir = home + "/.nnmaildir" nodir = home + "/.nnmaildir-not" maildirrel = "../maildirs" seen = {} for x in os.listdir(yesdir): seen[x] = yesdir + "/" + x for x in os.listdir(nodir): seen[x] = nodir + "/" + x exist = {} for x in os.listdir(yesdir + "/" + maildirrel): exist[x] = 1 if not seen.has_key(x): print "Adding symlink for mail folder " + x os.symlink(maildirrel + "/" + x, yesdir + "/" + x) for x in seen.keys(): if not exist.has_key(x): print "Removing symlink for mail folder " + x os.unlink(seen[x])