Rep: System Events versus Finder
Rep: System Events versus Finder
- Subject: Rep: System Events versus Finder
- From: KOENIG Yvan <email@hidden>
- Date: Fri, 29 Feb 2008 15:44:32 +0100
Le 27 févr. 2008 à 15:19, Matt Neuburg a écrit :
On or about 2/27/08 5:55 AM, thus spake "KOENIG Yvan"
<email@hidden>:
Perhaps you may explain if it is normal that
tell application "system events" to make new folder at <someFolder>
with properties {name:"myNewFolder"} fails when it is described by:
make v : Make a new object. [etc]
I guess my response is that I wouldn't give it any thought at all. The
dictionary gives no evidence as to what kinds of objects System
Events is
willing to make (and, of course, you never quite know from the
dictionary
what the precise expected syntax of "make" is going to be [p. 350]).
As a programmer, I'm naturally very lazy; since I already know
other ways to
make a new folder (e.g. the Finder, mkdir, etc.) I wouldn't even
bother
trying to get System Events to do it!
However, it can do it if you just bang away at it and work out (by
guessing)
what syntax it expects. For example, this works, as I discovered by
guessing
and testing:
tell application "System Events" to make new folder at end of alias
"feathers:Users:mattneub:Desktop:" with properties {name:"newFolder"}
But really, you know, expecting other people to do the guessing and
testing
instead of doing it yourself is *really* lazy! m.
The lazy guy is glad to be able to make a new item at end of its
folders but
this time I want to duplicate a file
Of course, I may do the job calling the Finder
set p2d to path to desktop as Unicode text
set source to (p2d & "calcDate.scpt") as alias
set destFolder to (p2d & "myFolder:") as alias
tell application "Finder"
duplicate source to destFolder
end tell -- to Finder
I may also do it using a shell script:
set p2d to path to desktop as Unicode text
set source to (p2d & "calcDate.scpt")
set destFolder to (p2d & "myFolder:")
set source to quoted form of POSIX path of source
set destFolder to quoted form of POSIX path of destFolder
do shell script "cp -p " & source & " " & destFolder
but, as I like to learn things,
I wonder if there is a way to do that using System Events.
It offers a function named duplicate which, at first read must be
able to do the job.
set p2d to path to desktop as Unicode text
set source to (p2d & "calcDate.scpt") as alias
set destFolder to (p2d & "myFolder:") as alias
tell application "System Events"
--duplicate source to destFolder (* fails *)
--duplicate source to end of destFolder (* fails *)
--duplicate source to the end of destFolder (* fails *)
end tell -- to System Events
The problem is exactly the same with move.
As my copy of your book is not already sold, I checked if you gave
the answer but didn't find it.
May you give some help here?
Yvan KOENIG
_______________________________________________
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