• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Removing duplicate messages in Mail.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing duplicate messages in Mail.app


  • Subject: Re: Removing duplicate messages in Mail.app
  • From: cricket <email@hidden>
  • Date: Mon, 24 Feb 2003 14:04:47 -0800

Messages all have a 'message id' property that can be used to see whether they are unique. One simple, but perhaps slow, way to do this would be to iterate over each message in a given mailbox, grab the message id and verify it against a list of message ids of messages you've already checked. If it matches, then move the message to the trash mailbox. If it doesn't match, add it to the list.

Something like:

tell app "Mail"
set messageIDs to {}
set everyMessage to every message of mailbox "Inbox" of account "MyAccount"
repeat with eachMessage in everyMessage
set thisMessageID to message id of eachMessage
if thisMessageID as string is in messageIDs then
set mailbox of eachMessage to mailbox "Trash"
else
set messageIDs to messageIDs & thisMessageID
end if
end repeat
end tell

If the mailbox is large, this approach doesn't scale well, but it should work nonetheless. A better approach (if performance is an issue) would be to sort the list of messages by some criteria (date, subject, etc) in your own data structure, then only compare any messages to their immediate neighbors, since the duplicate is likely a message right next to the current message.

In the next major release, we're working on adding the ability to get the list of messages in the sort order than displays in the UI, by using the message viewer class that was added in 10.2.3's scripting dictionary. This would allow you to use Applescript to sort a list of messages any way you like, then do neighbor comparisons without needing your own data structures.

- cricket

On Friday, February 21, 2003, at 00:59AM, Andrew Westcombe wrote:

Mail.app keeps the previous week's messages on my ISP's servers for a week, by default. A jolly good idea I think.

Trouble is, my ISP doesn't entirely understand this arrangement, and occasionally barfs up duplicate copies of many messages. So I'd like a script that identifies duplicate messages and moves them to the trash mailbox. Ideally, I could tell it to limit its search to a given range of dates.

Would anyone care to get me started?
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Removing duplicate messages in Mail.app (From: Andrew Westcombe <email@hidden>)

  • Prev by Date: Re: Scripting Mail:get selection
  • Next by Date: Re: Scripting Mail:get selection
  • Previous by thread: Removing duplicate messages in Mail.app
  • Next by thread: SOAP broken in Mac OS X 10.2.x? (Google Web API)
  • Index(es):
    • Date
    • Thread