Title: Re: Simplifying and Clarifying: Next Step
On or near 10/2/03 10:25 AM, Diane Ross at [EMAIL PROTECTED] observed:

> Worried about duplicates? Use this script to remove duplicates. I couldn’t
> find it on http://macscripter.net/scriptbuilders/. Allen is this your
> script? I didn’t see it on your script page either.
>
Hmm...could be. But I don't have a copy of it, so probably not. I have two scripts for removing duplicates, one by Barry Wainwright and the other by Paul Berkowitz. Paul's, called "Delete Imported Duplicates X", is on Scriptbuilders. Barry's isn't (you might want to post it there, Barry). His works off the message ID, which avoids false duplicate hits; it’s also fast. It's short, so here it is:

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

--
Microsoft MVP for Entourage/OE/Word (MVPs are volunteers)
Allen Watson <[EMAIL PROTECTED]> Entourage FAQ site: <http://www.entourage.mvps.org/>
AppleScripts for Outlook Express and Entourage:
 <http://members.thinkaccess.net/[EMAIL PROTECTED]/Scripts/>
Entourage Help Pages: <http://www.entourage.mvps.org/>

Reply via email to