I wrote this little tool to automatically purge my mailinglist folders on my IMAP account. I automatically move my incoming emails to their destination folders so all mailinglists I am subscribed to end up in separate folders.
For very busy mailinglists these folders fill up pretty quickly, e.g. the Linux kernel mailinglist, and since I had a disk quota of just 50 MBtye or so, I wrote this tool to clean up each folder individually.
You can specify a certain timeframe or a maximum number of messages for each folder. This way you get e.g. the last 30 days of a mailinglist or e.g. the last 750 messages of the list.
In case you want to discuss anything regarding this project, you can discuss it here.