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

Yet another method of trashing undeletable files System
In the past, I've used several apps that delete stubborn "you can't delete this file" files. However, I had a folder that the trial version of FileMaker Pro made that simply would not delete. The system said "That file is in use," despite my best efforts.

After several unsuccessful attempts at getting rid of the file. I found a completely successful way. I made a new user and gave it admin rights. Then I put the stubborn file in a common folder. Next, I logged on as the new admin user, and put the stubborn file in the trash.

Finally, I logged out and back in as the main user. Then I deleted the new user I created. The system then asked if I wanted to delete all files. And just like that, it was gone. This did what all these AppleScripts and apps couldn't seem to do.

robg adds: Over the years, this has probably been one of the more popular topics to discuss -- it seems there are many possible solutions. Even Apple has jumped into the discussion with their You can't empty the Trash or move a file to the Trash in Mac OS X Knowledge Base document. Suffice it to say, there should be something amongst these tips that works for your specific situation.

And yes, if you've been reading here for a while, the above editor's note was cribbed from an earlier deleting files hint (plus I added a few more links that have cropped up since the original was published).]
    •    
  • Currently 3.25 / 5
  You rated: 2 / 5 (4 votes cast)
 
[15,797 views]  

Yet another method of trashing undeletable files | 17 comments | Create New Account
Click here to return to the 'Yet another method of trashing undeletable files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Yet another method of trashing undeletable files
Authored by: kainewynd2 on Feb 14, '06 09:52:26AM

I guess I'm lucky - sudo rm -rf /path/to/filename has always worked for me... whether logged into the computer or over Target Disk mode... :D



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: mschaff on Feb 14, '06 10:21:52AM

Careful with throwing the Unix around. This is a surefire way for a Unix newbie to nuke all of his files. Perhaps before posting Unix commands like that, you comment them first.

To comment your command:
sudo = give full admin permissions to any command that follows
rm = remove file(s)
-fr = force recursively (including directories [a.k.a. folders])

It's the /path/to/folder part that is scary. If you inadvertently hit return after a single slash, your entire hard drive will be erased with no warning.



[ Reply to This | # ]
Pathname safety
Authored by: Rainy Day on Feb 14, '06 12:53:03PM
The safe way to enter fully qualified pathnames is to drag the file/folder icon you wish to delete to a Terminal window. The fully qualified path to that item will be automagically entered into the shell for you.

Ideally, you will have already typed your Unix command before doing that, so all you have to do is hit return, but i usually don't remember to do that beforehand. Fortunately, all you have to do is hit Control-A, which moves your shell cursor to the start of the line, and type the command (with a space at the end) then hit return (cursor can be anywhere on the line, doesn't have to be at the end).

You can also use cut and paste, or drag and drop text in the shell.

 

[ Reply to This | # ]

Pathname safety
Authored by: ManxStef on Feb 14, '06 01:03:03PM

Personally, if I'm doing an operation deemed "risky" such as rm -rf I always navigate down to the parent directory first, then use a relative path instead of an absolute e.g.

cd /path/to
sudo rm -rf delete

(Using tab-completion for the paths, too.) This is a fair bit safer IMO as you're a lot less likely to kill everything with a relative path than an accidental slash in an absolute.



[ Reply to This | # ]
Pathname safety
Authored by: sjk on Feb 16, '06 03:32:43PM

Good meta-hint!



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: jacobolus on Feb 14, '06 07:36:06PM

Just to be clear about the unix command. This always works for me:

sudo rm -rf ~/.Trash/*

This code will, with administrator priviledges, nuke everything in your trash. So if you can't delete something from the trash another way, this will wipe it.

The usual warnings apply. Sometimes a file can't be deleted because an application is currently using it (sometimes that application is part of OS X, and your computer will go wonky if the file goes away).



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: UberFu on Feb 14, '06 08:56:02PM

sudo rm -rf ~/.Trash/*
--

With the above command - you can pretty much leave off the ~ and everything after it and simply drag any of the file(s) or folder(s) you want to delete onto the Terminal window and press ENTER_

Also [at least in TIGER 10.4.x] They added a "Secure Delete" function in the FINDER MENU underneath the normal EMPTY TRASH Menu Item that will also handle any files that won't delete under normal circumstances_



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: jt777 on Feb 16, '06 12:56:50PM
Secure Delete is simply an srm -rf ~/.Trash/* NSTask. I don't think it handles permissions differently than a regular Empty Trash or rm would do. from man srm:
srm  removes each specified file by overwriting, renaming, and truncat-
       ing it before unlinking. This prevents other people from undeleting  or
       recovering any information about the file from the command line.


[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: novalies on Feb 14, '06 11:44:59PM

the freeware "SuperEmptyTrash.2.2" is very good and it will also emty trashes on external harddrives.



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: ianmac77 on Feb 14, '06 11:59:24PM
I think the seriousness of the above commands should be stressed. If you are new to unix, don't type them in. Its that simple, because if you add a space in the wrong area you could end up wiping out your entire hard drive.
For example, if you type
sudo rm -rf  ~ /.Trash/*
(notice the space) you would delete your entire home folder, and because the -rf is there, it will wipe out every folder inside of your home folder.
So please, don't skrew yourself over, ive done that before and it sucks. JUST DON'T TYPE IT IF YOU DON'T KNOW WHAT IT MEANS!

[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: Krioni on Feb 15, '06 08:35:57AM

Note to command-line junkies: even running the 'rm' command as root won't delete files that are locked (in the Finder's Get Info) window. Pain in the neck. Holding option while choosing Empty Trash will delete those, but not if the current user doesn't have permission.



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: jt777 on Feb 16, '06 12:50:53PM
Not sure I understand what you mean because it doesn't sound accurate. Try this:
  1. mkdir test
  2. touch test/test.txt
  3. get info on the file and folder
  4. set them both to locked.
  5. set them to no access for you, group, and others (or just chmod -R 000 test)
  6. verify this however you want
  7. sudo rm -rf test
  8. say "byebye" to the file and folder


[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: macgruder on Feb 15, '06 10:17:05AM

This hint:

http://www.macosxhints.com/article.php?story=20050928082624470

deals with how to prevent rm distasters. Basically:

$ ls something*
##### OUTPUT HERE
$ sudo rm -rf !$

What is about to be deleted will be listed at #####, so if a billion files appear you know you made a mistake before it turns into a distaster.



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: stam66 on Oct 19, '06 02:01:33PM

yes... all of the above methods do work. If you like wasting time that is.


Or you could just choose: Finder->Secure Empty Trash


For some reason this always works on those "undeletable" files (for me and for a couple of peeps i've shared this with). So throw away your terminal and your 3rd party utilities and just use the Finder.



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: superg on Oct 19, '06 09:04:25PM

DUDE. You rule! Worked great for me.



[ Reply to This | # ]
Yet another method of trashing undeletable files
Authored by: lipwak on Mar 12, '07 01:46:11PM

Me too. I should have tried this before looking but it worked for two OS9 files I was trying to delete.

Cheers,

John L



[ Reply to This | # ]
An easy way to delete a file.
Authored by: kayjay on Dec 16, '11 04:41:45PM

If your file (such as a word doc.x ) does not delete, simply close the item and go to FINDER and click on SECURELY EMPTY TRASH...
After several attempts of simply emptying my trash, I finally did this and it WORKED! THe terminal method is much too risky for an expensive computer (I would do it if it was a PC). Good Luck ALL!



[ Reply to This | # ]