• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to test if a Mail folder exists?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >How to test if a Mail folder exists? (From: Robert Nicholson <email@hidden>)

  • Prev by Date: Re: POSIX path with osascript
  • Next by Date: Re: Determining Binary Type
  • Previous by thread: Re: How to test if a Mail folder exists?
  • Next by thread: Numerical scripting
  • Index(es):
    • Date
    • Thread