I use mutt for that which modifies local maildir so it's super fast. Commands are: "D~=$". Then it's just a matter of syncing local changes back e.g. with mbsync.
- D tells mutt to delete messages by pattern
- ~= is pattern which selects all the dupes in current folder
- $ finalizes the command
I think this [1] is where I learned about it and there's also a handy folder hook for mutt which automatically removes duplicates when you open the folder.[1]: http://promberger.info/linux/2008/03/31/mutt-delete-duplicat...