Re: How to test if a Mail folder exists?
Re: How to test if a Mail folder exists?
- Subject: Re: How to test if a Mail folder exists?
- From: Christopher Nebel <email@hidden>
- Date: Fri, 29 Jan 2010 12:53:29 -0800
On Jan 23, 2010, at 7:32 AM, Robert Nicholson wrote:
> Is there a faster way than this?
>
> My script to move email seems to do it ever so slowly
>
> the idea is to test whether the mailbox exists first and create it if it doesn't.
>
> try
> set archiveMailbox to (mailbox folderName)
> on error
> log "Creating mailbox " & folderName
> make new mailbox with properties {name:folderName}
> end try
That works, but it's shorter (and probably clearer) to use the "exists" command:
if not exists mailbox folderName
log "Creating mailbox " & folderName
make new mailbox with properties {name:folderName}
end if
How sure are you that creating the mailbox is where the performance problem comes from? The typical performance problem with mass-sorting scripts is moving the messages one at a time (i.e., each message gets its own "move" command). It's faster (potentially *much* faster) if you move many messages at once using an "every" specifier of some sort.
--Chris Nebel
AppleScript Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden