I have a problem with Thunderbird. For some reason when I try to move a few thousand e-mails, in the destination folder the majority of messages get duplicates. Some could get 2 duplicates. I have no idea why. But I created https://github.com/gillius/imap-dupe-delete to clean up the mess. I built it for my own use and used it only on my own account. But it might be useful to others in the same situation or as an example of JavaMail usage from Groovy (as that is the language I used). I also used the GMavenPlus plugin to build from Maven. If you have Java and Maven it will be easy to run.