Trash & Deletion Problems [HELP!]

gibbs

Registered
I've got something in my trash, "temporary items" folder that I dragged from a freshly formatted partition. Now, it appears empty but there are invisible files, it wont let me change their permissions to delete, and trash wont empty it.

How do I get into my trash folder via terminal and delete this? Can I?

Any help would be most appreciated by the unix gurus. Thanks.
 
I solved my own prob with a search. [couldnt do it earlier, crashed web browser ;p ]

Thanks SO MUCH to Testuser for this-

Emptying the Trash - part II

Here's a more advanced shell script for emptying the trash in Mac OS X. It deletes the stubborn files & folders that refuse to be erased because they are either 1) locked or 2) have incorrect permissions or 3) both. It doesn't have any problems with spaces in the path name, so it should be safe. It can only be run by users who have administrative access.

It works great on Macs that have multiple partitions or hard drives.

There are three easy steps to set this up in the Terminal:
1) Make an executable directory:
mkdir ~/bin
chmod 700 ~/bin

2) copy the script below, and paste it into a text editor (like BBEdit Lite), and then save it with the name "trash" in your new "bin" directory (make sure to save with unix line breaks). If you want you can use the "pico" editor in the Terminal:
pico ~/bin/trash
now copy from the web page, and paste it into the Terminal. Exit pico and save the changes with the commands "Ctrl-x", then "y".

3) Make the script executable:
chmod +x ~/bin/trash
rehash

Now you can empty the trash any time by opening a Terminal window and giving the following command:
trash

Here's the script


code:
------------------------------------------------------------------------
#!/bin/sh
##
# Mac OS X script to empty the trash of stubborn items
# Please send suggestions for improvements to
# testuser at http://www.macosx.com
##

# Make checks before running the script
UID=`id -u`
if [ "$UID" -eq 0 ]
then
printf "Error: this script cannot be run as root or with sudo\n"
printf "Usage: trash\n"
exit 1
fi

# Check for trash on main and other volumes
printf "Must authenticate to empty trash. "
sudo printf ""
if [ -n "`ls ~/.Trash 2> /dev/null`" ]; then
mainTrash="full"
fi
if [ -n "`sudo find /Volumes/*/.Trashes/${UID}/* 2> /dev/null`" ]; then
otherTrash="full"
fi
if [ "$mainTrash" != "full" -a "$otherTrash" != "full" ]; then
printf "No items were found in the trash.\n"
exit 2
fi

# Empty the trash on the main volume; the one that is running OS X
if [ "$mainTrash" = "full" ]; then
printf "Emptying trash on main volume.\n"
sudo chflags -R nouchg ~/.Trash/* 2> /dev/null
sudo rm -Rf ~/.Trash/*
else
printf "No trash found on main volume.\n"
fi

# Empty the trash on other volumes; mounted at /Volumes
if [ "$otherTrash" = "full" ]; then
printf "Emptying trash on other volumes.\n"
find /Volumes/*/.Trashes/${UID}/* -prune -exec sudo chflags -R nouchg {} \;
find /Volumes/*/.Trashes/${UID}/* -prune -exec sudo rm -Rf {} \;
else
printf "No trash found on other volumes.\n"
fi
------------------------------------------------------------------------



Last edited by testuser on 02-11-2002 at 07:27 AM

THIS WORKS!!!!!!
 
If you want to do this from the GUI, there is a permissions utility called BatChmod that has an option to force empty the trash. It's a handy utility to have in your administrative toolbox:

http://www.macchampion.com:16080/arbysoft/

BatChmod is a Cocoa utility written by Renaud Boisjoly for manipulating file and folder privileges in Mac OS X.

It allows the manipulation of ownership as well as the privileges associated to the Owner, Group or others.

Here are some of the characteristics of BatChmod:

* It allows one to change any specific privilege or ownership without affecting the others
(ie, changing the group without affecting the owner, or adding or removing a specific privilege without affecting all the others).
* It can recursively affect enclosed folders.
* It can Force Empty the Trash, even when it contains locked files!
* It's extremely free!
 
The short answer is yes, it empties all .Trashes on all volumes for all users.

After choosing "Force Empty Trash" from the BatChmod menu, a warning dialog box comes up that reads "Are you sure you want to empty the trash? This will also empty the Trashes on all partitions and is not undoable." The dialog has "Cancel" and "Empty the Trash" buttons. Clicking on the "Empty the Trash" button requires one to authenticate as an administrator.

Their help file lists the following under "Force Emptying the Trash":

BatChmod offers a "Force Empty Trash" menu when you access from its Dock icon.

This command tries to set the privileges and unlock all of the items in the Trash and then empty the Trash.

The Finder does not always update the Trashe's icon properly, but the Trash should be empty... unless there is some other problem with the files.


So, use it with caution. It would be analogous to holding down the option key while emptying the trash under OS 9... every file, including locked ones, will be deleted.
 
Back
Top