Re: A quick question about moving files
Re: A quick question about moving files
- Subject: Re: A quick question about moving files
- From: patrick machielse <email@hidden>
- Date: Sun, 11 Sep 2005 13:22:20 +0200
Op 9-sep-2005, om 21:31 heeft applescript-users-
email@hidden het volgende geschreven:
At 13:51 +0200 UTC, on 2005/09/09, patrick machielse wrote:
tell application "System Events"
set t1 to folder "test1" of desktop folder
set t2 to folder "test2" of desktop folder
move disk items of t1 to (path of t2)
end tell
The result value here is: {missing value, missing value, missing
value}
Follow the advice you were given: use "path to" whenever you can.
(Which
really boils down to the more general advice of only targeting an
app when
you need to.)
set f1 to (((path to desktop) as string) & "foldername:") as alias
I refuse to program like this, that's just not 'english like'
anymore :-)
In my program I first create the target folder, so I already have a
reference to a folder inside the "System Events" context.
The working incantation seems to be
tell application "System Events"
set t1 to folder "test1" of desktop folder
set t2 to folder "test2" of desktop folder
move disk items of t1 to ((path of t2) as alias)
end tell
<broken record>
This is just another example of why I'm 'not fond' of AppleScript.
*) The "System Events" dictionary reads:
move disk item : The disk item(s) to be moved.
to location reference : The new location for the disk item(s).
It just completely fails to mention that by 'location reference' an
alias reference is meant, and that nothing else will do.
*) Any similarities with Finder exist _only_ to confuse
from the Finder dictionary:
move reference : the object(s) to move
to location reference : the new location for the object(s)
tell application "Finder"
set t1 to folder "test1" of desktop
set t2 to folder "test2" of desktop
move entire contents of t1 to t2
end tell
No alias required!
*) System Events fails silently
'move disk items of t1 to t2' completes, no error, no warning, just
the '{missing value}' returned.
</broken record>
I presume to the AppleScript insiders this is all "sliced
gingerbread" (as we say in the Netherlands), but to me it is all
quite surprising and it's slowing me down quite a bit.
I need
to move all files, including invisibles, so I need to use "System
Events", not "Finder" (correct me if I'm wrong).
I wasn't aware Finder.app ignores invisible files.
You have to find out for yourself. There is no documentation.
(I guess I don't script
Finder often.) If this is a problem, it might also matter how the
file was
made invisible. Mac OS X offers 2 or 3 different schemes for that.
Luckily I'm just interested in 'all' files :-)
patrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden