image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old June 25th, 2002, 02:02 PM
Registered User
 
Join Date: Jun 2002
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
gibbs is on a distinguished road
Arrow Trash & Deletion Problems [HELP!]

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.

Last edited by gibbs; June 25th, 2002 at 04:18 PM.
Reply With Quote
  #2  
Old June 25th, 2002, 04:51 PM
Registered User
 
Join Date: Jun 2002
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
gibbs is on a distinguished road
I solved my own prob with a search. [couldnt do it earlier, crashed web browser ;p ]

Thanks SO MUCH to Testuser for this-

Quote:
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!!!!!!
Reply With Quote
  #3  
Old July 11th, 2002, 08:32 PM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
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!
Reply With Quote
  #4  
Old July 11th, 2002, 10:48 PM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
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.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
shutdown problems, advice needed Gnomo Mac OS X System & Mac Software 3 April 29th, 2005 06:32 PM
[HOWTO] - Empty the trash of stubborn items swizcore HOWTO & FAQs 22 December 15th, 2002 04:12 AM
Problems emptying the trash emh_alpha1 Mac OS X System & Mac Software 0 February 27th, 2002 04:02 PM
problems w/ locked trash items and privledges edX Mac OS X System & Mac Software 1 December 17th, 2001 08:30 PM
Rename the Trash! mr_mac_x Mac OS X System & Mac Software 4 April 14th, 2001 02:37 PM


All times are GMT -5. The time now is 08:51 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.