Empty Trash

In OS9 I had following as part of script. It No longer works inOSX (as does heaps of other bits of script)
set locked of every item of entire contents of folder “Trash” to false
empty trash
Any help appreciated. Is there any script which will change OS9 scripts to OSX easily? :frowning:

Your original line worked because you happened to be running a North American or “International English” version of Mac OS 9, where the Finder’s name for the trash happened to be the same as the name of the trash folder on your hard disk - ie. “Trash”. (On my British English Mac OS 8.6 system, for example, the name of the invisible trash folder is still “Trash”, but it’s called “Wastebasket” in the Finder. Other languages presumably have their own equivalents.) The “correct” version of your line should be:

tell application "Finder"
  set locked of every item of entire contents of trash to false
end tell

In OS X, the name of the folder in your home folder is “.Trash”, but the Finder reports its name as “”. Unfortunately, the Finder scripting in X is such utter crap that even the correct form of the line doesn’t work and I haven’t yet been able to find a vanilla work-around that does. However, if you’re willing to use the X version of Jon’s Commands, the following seems to be a reliable trash emptier. Tested in 10.2.5.

tell application "Finder"
    get items of trash as alias list
  on error
    get items of trash as alias as list
  end try
  -- The following line requires Jon's Commands
  deleteFile result with unlocking without safety net
  update trash
end tell

The ‘deleteFile’ line unlocks files, even when they’re nested inside folders. The ‘update’ line makes sure that the icon in the Dock immediately appears “empty”.

I think that the X version of Jon’s Commands is downloadable from the OSAX section of this site. Create a folder called “ScriptingAdditions” (no space in the name) in the “Library” folder in your home folder, and install the OSAX into that.

Hope this solves the problem… :slight_smile:

Sorry. The “OSAX section of this site” is called “Scripting Additions” and I don’t think the version of “Jon’s” there is the X version. I’m using the X 3.0d3 version, which I downloaded from Jon’s Web page at http://www.seanet.com/~jonpugh/