Thunderbird and the Incorrect News Counter

While I am not completely happy with Thunderbird – the old and quite slow UI can be quite cumbersome – it is a nice application to offer an aggregated view onto all my mails, news and feeds. That’s something I like 🙂 And with Memotoo syncing to my Nokia Phone is easy and works flawlessly. Which I like even better 🙂

With one exception…. on both of my news accounts I do experience incorrect values for the counter showing the number of unread news. More precisely, I do end up with all visible mails being shown as unread yet the counter still showing unread messages. Well, not only me…

And if you are using shortcuts to jump to the next unread message like N you end up in these folders. Folders, where there is nothing to read for you.

Looking for a solution I found some comments which required the manual editing of some config files within the thunderbird profile. Doable, yes. But quite a nuisance if you have to do this every n-th day. And then I found the following python script on Reinouts site which does this automagically.

Python Skript:

 CONFIG_FILE = ('/home/reinout/.thunderbird-3.0/0gahkqdp.default/' +
               'News/newsrc-news.gmane.org')

 def fix_thunderbird():
    """Fix the thunderbird newsrc settings

    The settings sometimes contain lines like::

      gmane.comp.python.distutils.devel: 1-12428,12431-12446

    There's a two-article 'hole' in there that shows up as two unread
    messages.  This script removes the holes.

    """

    lines = [line.strip() for line in open(CONFIG_FILE).readlines()]
    print "======= OLD ======="
    for line in lines:
        print line
    print "======= NEW ======="
    outfile = open(CONFIG_FILE, 'w')
    for line in lines:
        if not line:
            continue
        newsgroup, messages = line.split(': ')
        parts = messages.split('-')
        new = '%s: %s-%s\n' % (newsgroup,
                               parts[0],
                               parts[-1])
        print new,
        outfile.write(new)
    outfile.close()

 if __name__ == '__main__':
    fix_thunderbird()