Can not delete directories which appear empty

dlarmour

Registered
When I put the folder (directory) into the trash it will not delete because it says it is being used. The directory has no visible contents (including through the terminal). I have tried rm inside the directory and then rmdir of the directory and still no go (it claims that the directory is not empty) . I don't see any files that start with a "." so that they usually are hidden. How do I make this stubborn directory and any truely hidden contents go away?

Thank you for your help.

David
 
What directory are you trying to remove?
If it's one used by the system, then it might be using files that are invisible. I'm not sure if all invisible files will show up in the Terminal.

If you are sure you want to remove the directory
type:

sudo rm -r "directory/you/want/to/delete"
 
I have a directory named temp-furthur which contains three directories each of which appear to be empty both from the Finder as well as the Terminal. When I try and empty the trash it comes back in use, while rm indicates the directories are not empty. I have tried

rm inside the directory

I can tell that the directories are not locked and I have full permissions (batchmod, chmod, the whole deal). I have even tried chflags, but the command returns that the flag nouchg is invalid.

Help??!!

David
 
Put the folder on the desktop and in the Terminal type
sudo rm -r ~/Desktop/temp-furthur

That will work.
 
Thanx

I tried that but the terminal response is:

Last login: Thu Aug 22 16:55:40 on ttyp1
Welcome to Darwin!
[24-196-147-92:~] darmour% sudo rm -r ~/Desktop/temp-furthur
rm: /Users/darmour/Desktop/temp-furthur/aru1994-03-26.shnf: Directory not empty
rm: /Users/darmour/Desktop/temp-furthur/gd1988-09-12.shnf: Directory not empty
rm: /Users/darmour/Desktop/temp-furthur/gd1993-06-26.shnf: Directory not empty
rm: /Users/darmour/Desktop/temp-furthur: Directory not empty
[24-196-147-92:~] darmour%
 
It *should* work because the -r flag means to recursively delete the directories inside it. I don't know why that wouldn't work.
 
this sounds a bit weird..

just to try a variation of devonferns technique

in terminal change directory to the one you are trying to delete and type

sudo rm -r *

this will remove *all* files in that directory

then try devonferns method again knowing that if anything was in the folder its not there anymore.

to see what is in the directory

type "ls -a"

( -a is the show all option)

you could also try "ls -Rpa"

im not sure of Mac OSX likes these options but this should show all the contents of all the folders. Dont what ever you do issue this command at the root of your drive. It will list every file and folder on your computer!

Hope this helps!
 
If it's only 3 folders inside another folder, why not move the inside folders to the trash individually, empty trash, perhaps problem stems from one empty folder only ?
 
Hi

I have tried to individually empty each folder into the trash. When I do that it returns that it can not be deleted because it is in use.

When I try sudo rm -r * the terminal response is that the directories inside of temp-furthur are not empty.

When a run ls -a (-Rqa) the only entries listed in each of the inside directories are:

"." and ".."

Any other suggestions?

David
 
try this: "rm .DS_Store"
this may or may not be the culprit...
also, use "ls -la" to view, this shows more information.
 
I tried everything and nothing worked. Finally I used Drive 10 and it appears to have corrected the problem. It did note however, that there were unusual changes -> so I can not as of yet guarantee that this utility did resolve the issue. I tried both fsck directly in single user mode and Disk First Aid both of which detected problems but were not able to fix them.

David
 
I have a similar folder, "temp", that I cannot delete because the Finder says the folder is in use and from the Terminal rmdir says the directory is not empty. What I have noticed about the "temp" is that located inside were 1 "." and 2 ".." To have it recursively remove the directories inside the folder would mean it would have to delete the folder that "temp" is in before it deletes "temp".

Alex
 
At the prompt, type:

rm -fr dirname

rm = remove file (unlike rmdir, which is remove empty dir)
-r = recursive
-f = force, interpret everything as a file, even directories
dirname = the directory you want to kill

Now, the -f tag is extremely dangerous, because with a command like rm -fr, you can blank a computer (as su) in mere seconds. So be careful when you use it, and be sure your dirname isn't something like "." or "..".
 
Back
Top