
Although cumbersome/not perfect, at least I was able to control the different steps and I knew what I was doing.Why are duplicates appearing in my iPhone/iPad or Android's native Contacts app? I'm sure someone could come with a safer or more elegant way to achieve this, but after several tentatives, this is what I decided to do.

Copying messages from local mailbox to the online one can be a long procedure, especially if you have big attachements. Why? No good reason, It's just that I didn't feel it was a good idea to copy everything in one shot. Note: I did not copy my entire local mailbox at once, I've split it in smaller batches of about 1000 messages. Then add again your online account to Mail (the mailbox should be empty), and copy the messages from local mailbox to online mailbox. Once you're happy with the content of your local mailbox, you can follow up with step 6, which is the stressful one, as you delete all your online messages (!) using the web interface.Clean your local mailbox and do some QC (random comparison) with the messages the cloud to make sure you didn't remove anything important. Then run Tidy Up who will scan and identify duplicates within your local mailbox only.Your original "messy" mailbox with all your duplicated messages is still available on the cloud via web interface, should you need it to run some random QC. This will remove the Mail mailbox as well. Remove your online account from your mac.Copy all the messages from your online account to the local mailbox. I assume you're using macOS Mail app: Create a local Mailbox.Tidy Up indeed searches across all mailboxes and I didn't find a way to specifically exclude some accounts/folders OK, I think I have to develop what I meant with the step 2 above (Take all messages off line): I then did some random QC again, between local folder and online one. Using Mail app, copied (not moved) the content of the local mailbox to the empty mailbox which is synced with the cloud.From that moment I didn't have anymore back up of my messages so I've quickly moved to the next step Delete all online messages on the cloud.Then do some random comparison/QC with online version to make sure I didn't erase anything important in my local mailbox, didn't corrupt anything, still have my attachements etc.Once it was cleaned, I've rebuilt the local mailbox (using "rebuild" function available in mailbox menu of the Mail app).
#ICLOUD MAIL REMOVE DUPLICATE MESSAGES FREE#
Then I've sort out and clean the local mailbox doing mass update/deletes using smart list, but also using a tool which identifies then remove duplicate messages and attachements.(I've purchased it on app store as I was ok to pay for it, but there are some free scripts available on community if you prefer).I've created a local mailbox on my Mac, and copied my 20,000 mails there (about 15 years of mailing) That doesn't work well because of the issues I've described above.
#ICLOUD MAIL REMOVE DUPLICATE MESSAGES UPDATE#
Don't try to run massive update or to clean mailbox while it is online and sync with (i)cloud repository anymore.OK, thanks for the help, here is my solution, inspired by your help and described with my own words:
