Re: Removing duplicate messages in Mail.app
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.