The subject is definitely not new; however, I have incorporated several suggestions from various folk as follows:
on emptytheTrash()
tell application "Finder"
if length of (items in the trash as string) is 0 then return
if not (folder "Empty Trash Temp" exists) then
set theFold to make folder with properties {name:"Empty Trash Temp"}
else
set theFold to folder "Empty Trash Temp"
end if
(*
CanNOT use this because the Finder can't see this folder - it's invisible.
set theFold to POSIX path of (path to temporary items folder)
As a result, AppleScript generates an error = "Can't get every item of trash":
*)
move every item in the trash to theFold
set locked of every item in theFold to false
delete theFold
empty trash
-- The following repeat loop delays the rest of the Script until the Trash is empty.
-- This repeat loop, based on time, prevents an endless loop if there is a
-- significant amount in the Trash.
-- suggested by Jon Pugh
set nbrTrashItems to length of (items in the trash as string)
set trash_loop to 0
repeat while (nbrTrashItems > 0)
set trash_loop to trash_loop + 1
if (trash_loop = 15 * minutes) then exit repeat
set nbrTrashItems to length of (items in the trash as string)
end repeat
end tell
end emptytheTrash
Boy, do I wish I could use the TemporaryItems folder because the System will automatically delete its contents upon reboot; so I’m forced to create a new “Empty Trash Temp” folder as was suggested on this Forum.
The ??? centers on the fact that every once in awhile (not all the time, by any means), the Finder will display a window that states something to the effect that a specific file is “busy”.
What’s interesting is that, for example, if this warning comes half way through the repeat loop, for example, I hit “Continue” and it does continue and does leave the one bothersome file in the trash. So far so good; but then I hit CMD-shift-delete and the bothersome file does get removed from the trash. Why, then, does the Finder produce this warning if all I have to do is hit CMD-shift-delete ??
The only way around this “busy” warning is to use “Secure Empty Trash”.
Is there another approach?
Thanks in advance