• 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: The difference between these two
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The difference between these two


  • Subject: Re: The difference between these two
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 1 Apr 2008 11:21:45 -0700

On Mar 28, 2008, at 7:02 AM, Jim Brandt wrote:

Can someone tell me what the difference between these two scripts is?

1)

tell application "Finder"
	activate
	set _today to "HD1:Today:"
	move contents of folder _today to trash
	empty trash
end tell

2)

tell application "Finder"
	activate
	set _today to "HD1:Today:"
	select every item of folder _today
	move selection to trash
	empty trash
end tell

When I ran these, the first script deleted both the contents of the folder AND
the folder itself.


The second one only deleted the contents, which is what I intended.

Is this a known bug?

Yes -- Finder implements "contents" of a folder incorrectly. (Of course, it also doesn't declare it in its dictionary, so trying to use it in the first place is inadvisable.) Incidentally, your scripts can be simplified, assuming you don't care about seeing the Finder do its thing: in the second one, you don't have to select and then move, you can simply say "move every item of folder _today to trash"; and the "activate" isn't necessary in either case.



--Chris Nebel AppleScript Engineering

_______________________________________________
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
  • Prev by Date: Re: iTunes: Why can't I get properties.
  • Next by Date: Re: Set Permissions on Files in OS X Shared Folder
  • Previous by thread: Re: iTunes: Why can't I get properties.
  • Next by thread: Re: [Sappho]
  • Index(es):
    • Date
    • Thread