Google Answers Logo
View Question
 
Q: AppleScript Sample ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: AppleScript Sample
Category: Computers > Software
Asked by: eager2learn-ga
List Price: $25.00
Posted: 29 Oct 2002 23:50 PST
Expires: 28 Nov 2002 23:50 PST
Question ID: 92923
I'm trying to learn AppleScript, and would like a simple script
written that would reveal a great deal to me. Assume I've got a
subfolder called "Friends" in a folder called "Archive" in MS Entourage X. 
I'd like a script that takes the highlighted message and moves it to the Friends
folder.
Answer  
Subject: Re: AppleScript Sample
Answered By: alexander-ga on 30 Oct 2002 09:18 PST
Rated:5 out of 5 stars
 
tell application "Microsoft Entourage"
	set curMsgs to current messages
	repeat with theMsg in curMsgs
		move theMsg to folder "Friends" in folder "Archive"
	end repeat
end tell

:)

Clarification of Answer by alexander-ga on 30 Oct 2002 09:33 PST
I should make that more lucid. I just couldn't resist such a clean and
concise answer. :)

I'm a professional Mac programmer, but truth be told, that's the first
AppleScript I've ever written. And it didn't take nearly as long as I
thought it would to figure out.

Why? Because I used a common approach to programming something one
doesn't know how to do: I looked for sample code.

Specifically, I downloaded two scripts from
http://www.applescriptcentral.com/ :

1) "Delete Junk Folder X":
http://www.applescriptcentral.com/ftpinwin.php?id=307

2) "File Reply in Same Folder X":
http://www.applescriptcentral.com/ftpinwin.php?id=348

The first contains code which gets a named folder:
set junkFolder to folder "Junk"

The second contains code which gets the selection:
set currMsgs to (current messages)

And code that moves messages:
move theMsg to theFolder

The syntax is easy enough to come up with thanks to AppleScript's
excellent syntax checking and highlighting. That, plus some
trial-and-error running of the script made it easy to narrow down the
commands to create a script that works.

Let me know if you have any questions, and thanks for the opportunity.
:)

Request for Answer Clarification by eager2learn-ga on 30 Oct 2002 17:47 PST
I'm grateful to you for giving this a whirl, but I'm getting an error
I can't quite understand. When it gets to the move command, it returns
the error: "Microsoft Entourage got an error: Can't get item 1 of
(incoming message id 44501)."  Any ideas?

Clarification of Answer by alexander-ga on 30 Oct 2002 18:31 PST
I was able to reproduce that error when there was no Archive:Friends
folder. It works when there a folder called "Friends" inside a folder
called "Archive" within "On My Computer". If you're is set up slightly
differently, it should be obvious how to change the code. Also make
sure there are no misspellings. :)

Request for Answer Clarification by eager2learn-ga on 30 Oct 2002 18:59 PST
My stupid mistake. The folder's name was " friends" (I had added the
space to change the ordering of the folders. Sorry for the extra
trouble, and thanks for the elegant solution.

Clarification of Answer by alexander-ga on 30 Oct 2002 20:24 PST
No problem. Glad I could be of help. :)
eager2learn-ga rated this answer:5 out of 5 stars and gave an additional tip of: $10.00
Accurate, and an excellent teacher too. Thank you.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy