Quote:
Note that you tell System Events to delete the files. If you tell Finder to delete them, it'll just move them to the Trash, cluttering up your Trash. (I hate it when programs do that. It's my Trash, for files I delete.)

You can tell Finder to delete the files, then send it the empty command, but of course this risks throwing out the baby with the bathwater for folks who use the Trash to hang on to items they're not quite ready to nuke.

Another way around the Console error issue is simply to quit Safari with a script which deletes the folder or its contents:

Code:
set thePath to ((path to library folder from user domain) as Unicode text) & "Caches:com.apple.Safari:Webpage Previews"
tell application "Finder"
	delete folder thePath --move "Webpage Previews" to Trash
	empty --warning: empties the Trash! Delete this line if you use the Trash to store stuff!
end tell
tell application "Safari" to quit

Or use System Events for the deletion. The point is that quitting (or launching) an app with an AppleScript script is an easy way to perform tasks which don't need to happen on a schedule as long as they happen more or less regularly. (Of course, this doesn't work if you're always up and never quit Safari, but I've never had so much RAM that Safari couldn't benefit from an occasional relaunch, even now that its memory leaks seem to be a thing of the past.)



dkmarsh—member, FineTunedMac Co-op Board of Directors