Re: Why won't the trash empty?
Re: Why won't the trash empty?
- Subject: Re: Why won't the trash empty?
- From: email@hidden
- Date: Sun, 17 Dec 2000 19:41:46 EST
In a message dated 12/17/00 7:20:42 PM,
email@hidden writes:
>
I've written this script as a stay-open app and everything works
>
fine...except the trash doesn't get emptied! If I run it from as a
>
regular script from the editor to test it (no handlers, etc) it works
>
fine. So, any idea what's up?
I've had the same problem. It turned out to be a timing error. From Script
Editor, it does not execute as quickly, so the trash has time to get the
files. When run otherwise, it's moving a little faster and the item(s) are
not in the trash yet. Here's how I fixed it:
tell application "Finder"
set sel to selection
if not (sel = {}) then
move sel to trash
(item 1 of contents of trash) as text
empty
end if
end tell
By adding the line "(item 1 of contents of trash) as text", it causes just
enough of a delay to allow the items to show up and the empty command works
correctly. This was contributed to me by someone else on this list last year.
Ken Fleisher
email@hidden