Re: AppleScript under OS X
Re: AppleScript under OS X
- Subject: Re: AppleScript under OS X
- From: Mr Tea <email@hidden>
- Date: Thu, 12 Feb 2004 15:33:46 +0000
On 11 Feb 2004, at 10.17 pm, Mark Gibson wrote:
Under OS X, I've tried to record a script but the "copy" and "delete"
actions don't seem to be in the Finder's dictionary anymore.
Hi, Mark.
Recording is a great way to start learning about scripts, but it
doesn't get you very far. Recorded scripts often contain a lot of
redundant code generated as you open windows and select the items you
want to do things with, and as you've discovered, the Finder is less
recordable in OS X than it was in previous OSes.
The following script, adapted for OS X from your original, demonstrates
that there is no need for all that window opening and selecting.
Applescript just goes right to the folders you specify and does what's
needed with a minimum of fuss.
--===========================================================
delay 20
tell application "Finder"
activate
set oldTemps to ((name of startup disk) & ":Applications:Microsoft
Office X:Templates:") as alias
set newTemps to alias "
DATA:Server II:Templates:"
set trashem to every item of oldTemps
delete trashem
duplicate every item of newTemps to oldTemps
empty trash
end tell
tell application "Microsoft Word" to activate
--===========================================================
(Any lines that abut the left margin of the message window have been
wrapped and should be re-connected to the end of the previous line.)
A couple of extra notes... Instead of the long-winded 'file "x" of
folder "y" of disk "z"' reference form that recording in the Finder
generates, I've used the more compact 'colon-delimited path' format
because it's more flexible and takes up less space.
You'll also have noticed that the term 'alias' crops up a couple of
times in the script. That's not the same as the alias files you create
in the Finder. In this context 'alias' is a reference form that allows
AppleScript to keep track of Finder items even if they are renamed or
moved to a different folder (but not to a different disk, which
involves duplicating a file and deleting the original).
HTH
Nick
pp Mr Tea
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.