Title: Re: Delete duplicates
On 6/4/02 4:36 pm, "William Humphrey"  wrote:

> Where can I find a utility that will delete duplicate contacts?
>

I posted this one a couple of weeks ago:


tell application "Microsoft Entourage"
    set theMessages to current messages
    if current messages = {} then
        set theFolder to selection
        if class of theFolder is folder then
            set mb to theFolder
        else
            display dialog "In the folder listing, please select the folder you want to be scanned for duplicates" with icon stop buttons {"Quit"} default button 1
            return -99
            
        end if
    else
        set mb to storage of item 1 of theMessages
    end if
    set theName to name of mb
    say "Removing duplicates from mail folder: " & theName
    set y to count messages of mb
    say "Number of messages to check, " & y
    set IDlist to {}
    repeat with x from y to 1 by -1
        try
            set theHeaders to (get headers of message x of mb)
            set AppleScript's text item delimiters to "Message-"
            set temp to text item 2 of theHeaders
            set AppleScript's text item delimiters to return
            set theID to text 5 through -1 of text item 1 of temp
        on error
            set theID to ""
        end try
        if theID is in my IDlist then
            delete message x of mb
        else if theID � "" then
            copy theID to end of my IDlist
        end if
        if x mod 100 = 0 then say "" & x
    end repeat
    set removedCount to y - (count messages of mb)
    if removedCount is 0 then
        say "Finished. No duplicates detected"
    else
        say "Finished. " & removedCount & " duplicates removed"
    end if
end tell
--
Barry Wainwright
<http://www.barryw.net>


"There is no reason why anyone would want a computer in their
home"� --  Ken Olson, DEC, 1977

Reply via email to