Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

How to restore a user's .Trash folder System
Summary: If you delete the trash folder (~/.Trash) and then recreate it, you must restart Finder before you can drag things to the Trash icon again.

Background/Explanation: I've been doing some disk housekeeping: deleting files, moving them around on external drives, etc. I somehow ended up with a copy of the Desktop DB file in the Trash. The file wasn't visible, but whenever I emptied the Trash, I got the annoying message The operation cannot be completed because the item Desktop DB is in use."

After clicking Continue, the Trash icon reverted to its apparently empty state, but the next time I put something in it and went to delete it, the same message appeared. I dropped to Terminal and thought I would just delete the file there, but it wasn't there. So I simply ran:
$ rm -rf ~/.Trash/
mkdir ~/.Trash/
Thinking that would solve the problem, and it did.

Except that the Finder was smart enough to tell that the ~/.Trash folder had been deleted, but not smart enough to tell that a new one had been created. So when I tried to drag a file there, I was told The file WHATEVER will be deleted immediately, continue?. I had to restart Finder (Option click-and-hold on its dock icon) to get it to work again.

[robg adds: I'm not sure I can explain why the Desktop DB file wouldn't have been visible. If you manually recreate your trash, you might also want to run chmod go= ~/.Trash, to remove all permissions from group and others. That will match the stock permissions on that folder. I'm not sure if Repair Permissions would catch this one or not.]
    •    
  • Currently 3.00 / 5
  You rated: 1 / 5 (5 votes cast)
 
[41,050 views]  

How to restore a user's .Trash folder | 9 comments | Create New Account
Click here to return to the 'How to restore a user's .Trash folder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How to restore a user's .Trash folder
Authored by: zacht on Dec 20, '06 07:57:18AM
I can't guess what was the situation on your computer, but it *might* have been something like this: sometimes files are placed not in ~/.Trash, but rather in a different trash folder. See the description here:

http://www.osxfaq.com/Tutorials/LearningCenter/HowTo/Trash/page2.ws

(scroll down to "Other Trashes"). Specifically, /.Trashes/501 (where more generally 501 is the user-id) can be a trash directory, and if there is more than one volume mounted there can be similar trash directories on each volume. Perhaps your Desktop DB file was placed into /.Trashes/501?

By the way, the linked article has a really nice collection of trash-related tips!


[ Reply to This | # ]
How to restore a user's .Trash folder
Authored by: macshome on Dec 20, '06 08:03:56AM

Why would you delete the whole .Trash folder? Why not ~/.Trash/* ?

---
http://www.afp548.com
Breaking my server to save yours.



[ Reply to This | # ]
How to restore a user's .Trash folder
Authored by: mbenchoff on Dec 20, '06 08:38:03AM
Yeah, I was going to suggest the following:

cd ~/.Trash
rm *

Much easier, IMHO.

[ Reply to This | # ]
How to restore a user's .Trash folder
Authored by: PCheese on Dec 20, '06 12:16:59PM

Because inevitably someone will add a space between the trailing slash and the asterisk, or they'll forget to do the cd command first. Oops, there go the contents of your home directory!



[ Reply to This | # ]
How to restore a user's .Trash folder
Authored by: rammjet on Dec 20, '06 10:21:47AM

Usually, if you try to delete a file in the Trash that is busy, first try holding down the Option key while emptying the Trash to force a delete.

If that doesn't work, then logging out and then back in will break the running process and allow you to delete the file. No deletion of any Trashes.



[ Reply to This | # ]
lsof
Authored by: SeanAhern on Dec 20, '06 11:44:24AM

Short of logging out, I find that the 'lsof' command will often find me the process that's using a given file. Terminating that program/process will often do the trick.



[ Reply to This | # ]
How to restore a user's .Trash folder
Authored by: DavidRavenMoon on Dec 20, '06 01:55:40PM
I'm not sure if Repair Permissions would catch this one or not.


I don't think it would, because there is no receipt for the trash.

---
G4/Digital Audio/1GHz, 1 GB, Mac OS X 10.4.8 • www.david-schwab.com • www.myspace/davidschwab • www.imanicoppola.net

[ Reply to This | # ]

How to restore a user's .Trash folder
Authored by: luomat on Dec 20, '06 02:59:31PM

Although you might THINK that rm -rf ~/.Trash/* would work, it DID NOT in reality, because according to the shell there were no visible files in there.

I always forget about the "Option" option when deleting trash.

Yeah I know I could have logged out or rebooted, but I thought this was going to be simpler.

@zacht: as soon as I deleted ~/.Trash/ the problem went away, so it wasn't an issue of the file being in /.Trashes/* but thanks for the link. Importing into Yojimbo now :-)



[ Reply to This | # ]
How to restore a user's .Trash folder
Authored by: wsdr on Dec 21, '06 06:26:04AM

Has it come to this? We're using the MacOSXHints comments for talking trash?

Sorry, couldn't resist.



[ Reply to This | # ]