The Entourage User's Weblog has been relocated.

You should be automatically redirected to the new location in 5 seconds. If not, please click on the link below.
Please remember to update your web browser bookmarks.

This page has been moved to

http://www.barryw.net/weblog/files/remove_duplicates.html.

html; charset=iso-8859-1" /> The Entourage User's WebLog
Removing Duplicates
I've been getting quite a few comments on my script to remove duplicate messages from a folder (Remove Duplicates v1.0, available from this page). I don't know why it has suddenly hit the radar, because that script is over four years old!

Anyway, I wrote it for a specific purpose, and from what I can gather, it seems to be quite a common task that people want to do. For whatever reason, many people end up with duplicate messages in their mail folders, and this script quite neatly removes them. It works on the 'current folder', which may be a folder selected in the folder list, or the containing folder of a selected or open message. It then scans through the folder, removing the newer versions of any duplicate messages.

How does it identify a duplicate? Well, other scripts I have seen rely on a combination of the subject and the sent date of a message, which is probably reliable 99.9% of the time, but is not guaranteed to be error free. Instead I use the 'Message ID' header within a message. This is unique to each mail message - unique not only to you, but throughout the known universe! If two messages in your database have the same Message-ID header, they ARE duplicates.

Now, folders can contain thousands of messages. To scan a folder comparing each message to a list of message-ID's of all the other messages can take a long, time For this reason, I wanted to give some feedback to the user. Trouble is, Applescript has no 'built in' method of displaying messages or progress bars (other than a dialog box with a button, which is messy and delays execution of the script). There are third party utilities available, but I couldn't reasonably expect other users to have them installed (or expect them to install these tools just to use my script). What every mac does have is audio. So, I arranged for the script to 'speak' it's feedback. Therefore, the script gives you a summary at the start of it's run, a countdown through the run and a summary at the end as to how many messages were deleted. This causes the minimum possible delay to the run time of the scritp and seemed like a good way to give unobtrusive feedback.

Of course, it catches some people out - I have had a message from someone in an office placement who used this script, but didn't know about the feedback because he always had his mac muted! Ah well. You can't catch every situation!

Please feel free to leave a comment using the links below - comments on this article or requests for future articles are always welcome and will be responded to where appropriate.
|