Title: How to Applescript deletion of multiple items?
Problem: when I’m offline I flag messages that I want to come back to when I’m back on the Net (to look up URLs and the such).  So I’d like to have a command that deletes all of the messages in a folder EXCEPT the ones I have flagged.

For a while I just tried sorting and deleting the rest, but that was just annoying.

Applescript to the rescue: I wrote the following script, which works just fine.  But it’s darned slow.

tell application "Microsoft Entourage"
    set StartTime to the current date
    set currMsg to the current messages as list
    set MsgCount to count of currMsg
    set NoFlagMsg to {} as list
    say (MsgCount as text) & " items to check"
    repeat with eachMsg in currMsg
        if flagged of eachMsg is false then
           copy eachMsg to the end of NoFlagMsg
        end if
   end repeat
   repeat with eachItem in NoFlagMsg
        delete eachItem
        set MsgCount to MsgCount - 1
        if (MsgCount mod 25 = 0) and (MsgCount > 0) then
           say (MsgCount as text) & " to go."
        end if
   end repeat
   set ElapsedTime to (current date) - StartTime
    say "Elapsed time: " & ((ElapsedTime div 60) as text) & "  minutes " & ((ElapsedTime mod 60) as text) & " seconds."
end tell

The main problem is in that delete loop: it deletes the messages one at a time, and on my system (500 mHz G4) takes about 3-4 seconds per 25 emails.

What I really want is this:

delete every item in NoFlagMsg

which responds that every item doesn’t understand the command.  What’s the right syntax to do this in one fell swoop?

Best,
Jeff Porten


Reply via email to