Applescript Mail duplicate removal

Hi all,
I have a problem with duplicate email messages and thought I'd take a stab at an applescript solution.  Tried using a few sorting/searching type strategies but the size of the mailboxes just made it too slow and unwieldy.  But I noticed that in the viewer, duplicate messages are not visible.  (Seems like if Mail has the ability to notice duplicates it should just as easily make it an option to flush them, but maybe I'm naive.)  Anyway, thought I would use that knowledge to remove duplicates myself with the script below.  It works so far, but my concern is whether there are *any* reason a message would not be visible yet not a duplicate.  Does anyone know?  This is lightning fast compared to my other attempts and so far seems to only find duplicates.
tell application "Mail"
          set theViewer to front message viewer
          set msglist to visible messages of theViewer
          set IDlist to {}
          repeat with msg in msglist
       copy (id of msg) to end of IDlist
          end repeat
          set allmsgs to messages of theViewer
          set dupcount to 0
          repeat with msg in allmsgs
                         if (id of msg) is not in IDlist then
                                        move msg to mailbox "Deleteme" of account "myaccount"
                                        set dupcount to dupcount + 1
                        end if
          end repeat
          say "Moved " & (dupcount as rich text) & " messages to mailbox deleteme"
end tell

Did you have any luck with this script as I have also been looking for something to do this, at the moment I'm having to use Entourage to perform the function.

Similar Messages

  • Mac Mail DUPLICATES removal?

    i am trying to google this and it appears that the scripts that someone posted don't work in Mountain Lion or Lion?
    does anyone know how to do this other than setting up all my accounts in Thunderbird and having Thunderbird do this?
    TIA

    Google have a Recommended IMAP client settings page which covers five different clients including Apple Mail which you can find here
    I use these settings and hope it helps.

  • I want to download the "FREE" iPhoto duplicate remover software, but the download process keeps asking me for my payment information.

    I want to download the "FREE" iPhoto duplicate remover software, but the download process keeps asking me for my payment information. I have tried it several times.. But it says I cannot download this app unless I give my payment information.. So I went back and looked again and again.. and it still says it's "Free"...

    You need to contact the authors re download or payment issues - we are only users like yourself and help with iPhoto for the Mac issues
    here is Old TOad's list of potential packages including his comments
    These applications will identify and help remove duplicate photos from an iPhoto Library:
    iPhoto Library Manager - $29.95
    Duplicate Annihilator - $7.95 - only app able to detect duplicate thumbnail files or faces files when an iPhoto 8 or earlier library has been imported into another.
    PhotoSweeper - $9.95 - This app can search by comparing the image's bitmaps or histograms thus finding duplicates with different file names and dates.
    DeCloner - $19.95 - can find duplicates in iPhoto Libraries or in folders on the HD.
    DupliFinder - $7 - shows which events the photos are in.
    iPhoto AppleScript to Remove Duplicates - Free
    PhotoDedupo - $4.99 (App Store) -  this app has a "similar" search feature which is like PhotoSweeper's bitmap comparison.  It found all duplicates
    Duplicate Cleaner for iPhoto - free - was able to recognize the duplicated HDR and normal files from an iPhone shooting in HDR
    Some users have reported that PhotoSweeper did the best in finding all of the dups in their library: iphoto has duplicated many photos, how...: Apple Support Communities.
    If you have an iPhone and have it set to keep the normal photo when shooting HDR photos the two image files that are created will be duplicates in a manner of speaking (same image) but there are only twp apps that detected the iPhone HDR and normal photos as being duplicates: PhotoSweeper and Duplicate Cleaner for iPhoto.  None of the other apps detected those two files as being duplicates as they look for file name as well as other attributes and the two files from the iPhone have different file names.
    iPLM, however, is the best all around iPhoto utility as it can do so much more than just find duplicates.  IMO it's a must have tool if using iPhoto.
    LN

  • Adding mail ids & Removing mail ids from the last step of process chain

    Hi
    Can you please guied me how to do this.
    Adding mail ids & Removing mail ids from the last step of process chain.
    Thanks
    Subbu

    You can refer the following thread.
    email alert for process chain
    Still I would suggest to search the forum. There will be many threads and articles on this which can help you out.

  • How can I stop automatic spelling and grammar corrections?, Iwill send him another. Mail keeps removing the space after I

    , Iwill send him another. Mail keeps removing the space after I

    have opened the "Spelling and Grammar" -Ijust did it again and found 'correct spelling automatically' Ihave now turned it off. Ihope that fixes my problem. no, it has not , as you can see this email has the same problem.
    Paul Morrow

  • Disabling Mail. Removing its icon from my Dock

    I'm perfectly happy to use gmail directly without using Mail.
    Mail often boots itself and the icon in the Dock bounces. I know I can turn off the bounce, but how can I either disable Mail or remove it altogether?
    Also, there's a Mail icon on my Dock that I'd like to remove but cannot. How can I accomplish that?
    Thanks in advance.
    Dave

    Try resetting the Dock settings file. First, open Finder, select Go menu (on the menu bar) > Go to Folder, and type ~/Library/Preferences. Then, delete "com.apple.dock.plist" and restart the Mac. Finally, try to delete Mail again.
    Also, when you are going to turn the Mac off, make sure that Mail is closed or that you untick "Reopen windows when logging back in". If you don't do one of those things, Mail will start automatically every time you start the computer

  • Hi! I am a Creative Cloud member. I use my e-mail " Removed by Moderator " when I was applying. Why it keep sending mails to my another e-mail account " Removed by Moderator " which is already shut down?

    Hi! I am a Creative Cloud member. I use my e-mail <Removed by Moderator> when I was applying. Why it keep sending mails to my another e-mail account <Removed by Moderator> which is already shut down?
    Because it sends validation mails to this account, I cnnot receive anything and sign in the Creative Cloud!!

    Some Change/Verify Account links https://forums.adobe.com/thread/1465499 that may help
    -email address https://forums.adobe.com/thread/1446019
    -http://helpx.adobe.com/x-productkb/global/didn-t-receive-expected-email.html

  • Mail duplicates mailboxes

    Just upgraded to Tiger and now Mail duplicates my .Mac Account, giving me one mailbox with that name, besides my actual account name. Can't get rid of either. When trying to deactivate in Preferences it won't save because both have the same account path ! What to do?
    iBook G4   Mac OS X (10.4.3)   933 MHz 640 MB 15GB available

    Not certain, but this can fix myriad Mail problems...
    Safe Boot from the HD, (holding Shift key down at bootup),  it will try to repair your Disk Directory while the spinning radian is happening, so let it go, run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, then move this folderto the Desktop.
    Move this Folder to the Desktop...
    /Users/YourUserName/Library/Caches/Mail/
    Reboot, then in Mail highlight each Inbox & choose Rebuild from the Mailbox menu item.

  • Why does 4.5 mail keep removing emails that are 10 days old

    Why does 4.5 mail keep removing  emails that are 10 days old.

    Ten days isn't an option I'm familiar with; perhaps it's a new option in Lion? Prior OS's had choices like one day, week, month, etc.
    If not being apparently set in your email client, it's possibly been set or is set by default at the server level. To check and change that you'll have to access it directly, usually by logging into that domain directly.

  • Applescript Mail Remove Attachments

    Hi,
    Can anybody help with this?
    I want a Mail rule to remove any attachments received from a particular sender. There is no built in rule for this so figure an applescript could do the job, but I haven't managed to get one to work.
    There is a person whose messages I need to read, but he insists on attaching >10MB images with each message.
    Many thanks,
    D

    This looks more than a job that needs to be done by your mailserver :-/
    When you would use a pop account you could run a script on the emlx files in your Mail-Folder and remove the attachments but this could lead to inconsistent data (hacked emlx file and you mail database).. The cleanest way would be a mailserver that filters attachments.

  • Mac Mail (Lion) DUPLICATES remover?

    i am trying to google this and it appears that the scripts that someone posted don't work in Mountain Lion or Lion?
    does anyone know how to do this other than setting up all my accounts in Thunderbird and having Thunderbird do this?
    TIA

    Any suggestions?
    My mail is still not functioning and crashes everytime I open it or check archived messages.

  • Mail Duplicates IMAP account Snow Leopard

    Hey everyone-
    I'm getting duplicate emails on an IMAP account- I know there is another post about this issue, but it seems to mostly pertain to POP emails, but nothing I've read or seen on this forum or any other has yet helped me. Also I don't know if my situation is exactly the same as the others. I will try to include all factors that may (or may not) be relevant.
    -Model and OS, you can see in my signature line.
    -IMAP email account that worked previously in Leopard. Also, this email account works perfectly on wife's macbook using the exact same settings. This account works on iPhone 3GS, on Thunderbird for XP and Outlook for XP. Further, this email account works on a seperate user account I created on my MBP just to test Mail.
    -When I try to mark the duplicate emails as "read" from within Mail, there is a squiggly upward arrow that appears next to the message-I'm assuming Mail is trying to tell me something-anybody know what?
    -I have done the following with no result: deleted cache, verified/repaired disk permissions, deleted and added mail account (multiple times, including Library files related to this account), restarted in "safe" then restarted again (per Apple tech support), and reinstalled Mail directly from SL disk (again multiple times).
    -Since I'm beginning to think its related to my specific user account, it may also matter that this user account has been migrated from iBook G4 12" 1.33 Tiger, then to this MBP Leopard when it had a 200GB HDD, upgraded to SL, then again to the 500GB HDD.
    I'm at my wit's end. Willing to take any measure, including completely removing Mail itself. Every mail account I use is IMAP or Exchange, it would be a pain to have to put them all back on (I use like 6 emails accounts), but anything to get Mail working again.
    Peace
    Curtis

    I should also mention deleting preferences files, and that this is NOT a gmail account.

  • Sent mails duplicate copies in Inbox

    I have setup a POP gmail on Mail 4.1. It seems that every mail sent from my Mail app, it will forward a copy to my inbox right away. (It's already unchecked on the Composing tab, that says "Automatically cc: myself")
    Is there any way to stop this? Thanks in advance!
    Des

    V.K. wrote:
    desmawn wrote:
    I have setup a POP gmail on Mail 4.1. It seems that every mail sent from my Mail app, it will forward a copy to my inbox right away. (It's already unchecked on the Composing tab, that says "Automatically cc: myself")
    it looks like that option was not cleared in the mail preference file.
    try checking that option. close mail preferences. then open mail preferences and uncheck that option. see if that helps.
    Hi VK, appreciate your information, but it's still sending the mail back to my inbox again. I wonder if I might have messed up with some applescripts earlier that I have used to delete duplicates messages in mail. Is there any way to undo applescripts? (in case it's the script that triggers my problem.)
    Once again, thanks!

  • Mail Duplicate Issue

    I have a strange issue with my clean install of Mavericks. I set up my two email accounts and emails were imported both using IMAP. I have an issue with emails received from this Apple Support Community that is it. They are doubling every message. But the amount of emails in the column is the correct but within the conversation each message is doubled. These emails go to my yahoo account and accessing the email through yahoo doesn't show these duplicates, so that means something within Mac Mail is causing these duplicated messages within these conversations. As you can see in the attached image the conversation states 2 emails within its contents. However looking on the right the total is 4 (number in top right corner) because every message is doubled. Any help in resolving this would be appreciated. Already deleted the account and recreated and resulted in same results.

    Last time I saw the number on my machine it said something like 96 of 96 messages. None of my local folders have 96 messages in them, and I don't think any messages actually downloaded at that time.
    Could be that there are messages still on the server that the iMac has already downloaded. Is your machine configured to delete messages from the server after downloading? It could be that you have that many on the server that have already been downloaded.
    I just checked my account setup, and for the two I use I clicked the button saying "Delete now" to remove previously downloaded messages from the server. Now it's grayed out so maybe that is what the number represents.

  • Mail.app: 'Remove Address' does NOT Remove Address

    Hello,
    I am using OS X (10.9.5) running Mail.app (7.3 (1878.6)).
    When I reply-all to an email with multiple recipients in the CC line, if I right-click and 'Remove Address', it removes the address from the CC: line, and appears that the message will not go to this recipient.
    When I check my 'Sent' folder for this outbound message, I can see that all recipients that I removed by right-click > 'Remove Address' actually received the message that was not addressed to them.
    I can readily duplicate this failure with test email addresses.
    This is a critical defect.  Mail should not be delivered to unexpected recipients.  Mail should SPECIFICALLY not be delivered to recipients that have been explicitly removed from any of the address fields.  If the Remove Address feature does not work, perhaps remove it from the right-click options.
    Please fix this.
    I am aware of a workaround to use the 'Delete' key to remove addresses.  I will use that in the future.
    This violates the principle of least surprise in one of the worst possible ways.
    Similar post (Why won't Mail remove a recipient's address when I manually do it?)

    Apple doesn’t routinely monitor the discussions. These are mostly user to user discussions.
    Send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.
    Mail/Provide Mail Feedback

Maybe you are looking for