• 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: A quick question about moving files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A quick question about moving files


  • Subject: Re: A quick question about moving files
  • From: deivy petrescu <email@hidden>
  • Date: Sun, 11 Sep 2005 09:58:49 -0400


On Sep 11, 2005, at 7:22, patrick machielse wrote:

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

This script below copies all files, including invisibles, but there is no way of telling system events to replace the old files by the new files (with replacing), so for instance, .DS_Store files are going to cause an error.
And, you are right, the dictionary should say;


to location: a reference to the new location for the object(s)

a reference is an alias.

<script>
tell application "System Events"
set t1 to (folder "test 1" of desktop folder) -- I would write alias here too, but just stressing your point.
set t2 to (alias "test 2" of desktop folder)
try
move every item of t1 to t2
end try
end tell
</script>


deivy
_______________________________________________
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


References: 
 >Re: A quick question about moving files (From: patrick machielse <email@hidden>)

  • Prev by Date: Re: How to tell if "Save" failed
  • Next by Date: bug with editing buggy applet bundle in Script Editor
  • Previous by thread: Re: A quick question about moving files
  • Next by thread: Re: A quick question about moving files
  • Index(es):
    • Date
    • Thread