Deleting large directories

J

John Stubbings

Vista Business

Keep having problems deleting large directories. Errors relating to sub
directories not empty. I have to keep drilling down directories until I can
delete files. I've reset permissions and taken ownership both using the GUI
and command line till I'm blue in the face nothing helps. Run chkdsk says
all OK.
 
G

gs

have you try the following ( use with Caution: Be careful)?
rd /s theDirYouWantGone

from command line
if you still have trouble there may be files/directory you don't have
access or marked protected somehow

Also remember not all files or folders are actually residing where they
appear
 
K

keepout

Vista Business

Keep having problems deleting large directories. Errors relating to sub
directories not empty. I have to keep drilling down directories until I can
delete files. I've reset permissions and taken ownership both using the GUI
and command line till I'm blue in the face nothing helps. Run chkdsk says
all OK.

use the DOS interface. CD to the directory above the one you want to delete
ie:

C:\temp\temp2
CD to C:\temp

then use RD /s /q temp2.
GONE.....

or start - start search box - CMD - CD to C:\temp\ or whatever the directory
above the directory you want to remove is located.

then use RD /s /q directory_name_you_want_to_delete.
GONE.....

If it's a big name for the root directory, try and rename it before you go to
dos, and [COPY] the file name into the clipboard instead of renaming.

then use RD /s /q [PASTE from clipboard] "extremely long directory name with
spaces that make the name useless and hard to delete"

don't forget the quote marks around the name.

GONE.....
If you can't do it, turn UAC off and repeat.
 
J

John Stubbings

Vista Business

Keep having problems deleting large directories. Errors relating to sub
directories not empty. I have to keep drilling down directories until I can
delete files. I've reset permissions and taken ownership both using the GUI
and command line till I'm blue in the face nothing helps. Run chkdsk says
all OK.

use the DOS interface. CD to the directory above the one you want to delete
ie:

C:\temp\temp2
CD to C:\temp

then use RD /s /q temp2.
GONE.....

or start - start search box - CMD - CD to C:\temp\ or whatever the directory
above the directory you want to remove is located.

then use RD /s /q directory_name_you_want_to_delete.
GONE.....

If it's a big name for the root directory, try and rename it before you go
to
dos, and [COPY] the file name into the clipboard instead of renaming.

then use RD /s /q [PASTE from clipboard] "extremely long directory name with
spaces that make the name useless and hard to delete"

don't forget the quote marks around the name.

GONE.....
If you can't do it, turn UAC off and repeat.
--
more pix @ http://members.toast.net/cbminfo/index.html



Done all of that, it's a permissions issue, but taken ownership and full
control etc command line and GUI and rd /s and no joy. It's a pain, errors
like cannot delete directory contains files, or you need permission to
delete this file, and click through UAC fails
 
K

keepout

If you can't do it, turn UAC off and repeat.
--
more pix @ http://members.toast.net/cbminfo/index.html



Done all of that, it's a permissions issue, but taken ownership and full
control etc command line and GUI and rd /s and no joy. It's a pain, errors
like cannot delete directory contains files, or you need permission to
delete this file, and click through UAC fails

You turned off UAC, then tried what I told you ?
If you have no use for permissions, you can do like I've done. Takes awhile on
a large drive. Maybe an hour or a bit less.

But I no longer have to tell the machine to do something 2 or 3 times or more.
I hit a button and it almost always does what it's told.

I also trust my virus software to take up where UAC, and all the windows
security fails.

right click C:\
or just the folder you want permission. This assumes you have permission to
change permissions.

PROPERTIES - SECURITY tab - USERS - ADVANCED, [1] - PERMISSIONS - USERS -
USERS - toggle REPLACE all existing & inheritable etc.. from object - EDIT -
toggle FULL CONTROL ON. should toggle all below, users should be selected.
Apply to this folder, sub folders & files. [this one should really take some
time] more than 10,000 files and 700 folders for me.
But it normally only has to be done once.

[1] OWNER tab - edit - select you - toggle 'replace owner on sub containers &
objects' apply [may take some time, get a drink or lunch.]

You're positive you have UAC off ?
 
A

Andrew McLaren

John Stubbings said:
Keep having problems deleting large directories. Errors relating to sub
directories not empty. I have to keep drilling down directories until I
can
delete files. I've reset permissions and taken ownership both using the
GUI
and command line till I'm blue in the face nothing helps. Run chkdsk says
all OK.

I guess you're using "rd /s" after using takeown and icacls commands, to
take ownership and grant yourself permissions recursively to all
subdirectories and files in the tree?:


C:\>takeown /F C:\MyDirectory /R /D y

C:\>icalcs C:\MyDirectory /grant:r John:F

I'll assume you've done this and you're still seeing problems.

Normal Win32 commands cannot delete a file or directory whose pathname is
more than 260 characters long. If your large directory has many long
pathnames, that may be the problem (see for example,
http://support.microsoft.com/kb/320081). The best workaround I have found
for this is to use the "rmdir" command in the Services for Unix subsystem.
POSIX commands are not subject to the Win32 MAX_PATH limitation. But not
everyone has the Unix subsystem installed (if not, why not? :). The next
alternative is to shorten the path names, begining from the top, so that the
path gets to less than 260 chars. So, if you have a path like this:

C:\Directory1\Subdirectory2\subdirectory3\subdirectory4\subdirectory5\...
etc

start by renaing "Directory1" to a single character, such as "1". Then try
"rd /s c:\1" again. If it still complains, renames Subsdirectory2 to a
single char, such as "2". And so on. Eventually, the longest path in the
tree will get back down under 260 chars in length, and the whole tree can be
deleted.

This will only work if the obstacle is the length of the pathnames. If you
are being prevented from deleteing files because they are in use, or you do
not have permissions etc, you will need to use other steps to correct the
problem.
 
J

John Stubbings

Andrew McLaren said:
I guess you're using "rd /s" after using takeown and icacls commands, to
take ownership and grant yourself permissions recursively to all
subdirectories and files in the tree?:


C:\>takeown /F C:\MyDirectory /R /D y

C:\>icalcs C:\MyDirectory /grant:r John:F

I'll assume you've done this and you're still seeing problems.

Normal Win32 commands cannot delete a file or directory whose pathname is
more than 260 characters long. If your large directory has many long
pathnames, that may be the problem (see for example,
http://support.microsoft.com/kb/320081). The best workaround I have found
for this is to use the "rmdir" command in the Services for Unix subsystem.
POSIX commands are not subject to the Win32 MAX_PATH limitation. But not
everyone has the Unix subsystem installed (if not, why not? :). The next
alternative is to shorten the path names, begining from the top, so that
the path gets to less than 260 chars. So, if you have a path like this:


C:\Directory1\Subdirectory2\subdirectory3\subdirectory4\subdirectory5\...
etc

start by renaing "Directory1" to a single character, such as "1". Then try
"rd /s c:\1" again. If it still complains, renames Subsdirectory2 to a
single char, such as "2". And so on. Eventually, the longest path in the
tree will get back down under 260 chars in length, and the whole tree can
be deleted.

This will only work if the obstacle is the length of the pathnames. If you
are being prevented from deleteing files because they are in use, or you
do not have permissions etc, you will need to use other steps to correct
the problem.


Thanks, yes used rd takeown and icalcs as you say. Thought about directory
length, but I can copy directory to my Desktop and delete that, this has
slightly longer path, and I can go into subdirectories and delete from
there.

I don't think Services for Unix subsystem is available for Vista Business
just Ultimate, unless you know different? Good idea though. To be honest
this should just work, I don't have any problems on XP, Windows 98, Linux,
Windows server 2003....

This all seems to have started when I copied some files from a Windows 98
and a Linux computer over the network. The fix seems to be to copy the
directory and spend an hour or two deleteing the old directory bit by bit.
Pain, I had to do this several times so far when restructuring my data.
 
A

Andrew McLaren

This all seems to have started when I copied some files from a Windows 98
and a Linux computer over the network. The fix seems to be to copy the
directory and spend an hour or two deleteing the old directory bit by bit.
Pain, I had to do this several times so far when restructuring my data.

What is the exact text of the error message you get, if you do a "rd /s" on
the tree?
 
D

Dave Cox

Thanks, yes used rd takeown and icalcs as you say. Thought about
directory length, but I can copy directory to my Desktop and
delete that, this has slightly longer path, and I can go into
subdirectories and delete from there.

I don't think Services for Unix subsystem is available for Vista
Business just Ultimate, unless you know different? Good idea
though. To be honest this should just work, I don't have any
problems on XP, Windows 98, Linux, Windows server 2003....

This all seems to have started when I copied some files from a
Windows 98 and a Linux computer over the network. The fix seems to
be to copy the directory and spend an hour or two deleteing the
old directory bit by bit. Pain, I had to do this several times so
far when restructuring my data.


Did you copy the directories to your C:\Users\(your user name)\
folder?


If you work with files or directories under your user account and
folder you shouldn't have any issues working with files or
directories.
 
K

keepout

This all seems to have started when I copied some files from a Windows 98
and a Linux computer over the network. The fix seems to be to copy the
directory and spend an hour or two deleteing the old directory bit by bit.
Pain, I had to do this several times so far when restructuring my data.

I'm just guessing, but I installed a HD from my XP machine with all files
intact.
There was now a New numeric [12-0-3-67-hy-56] etc... user in the owners..The
fix was to delete that numeric user and take the permissions the way I showed
you.
 
J

John Stubbings

This all seems to have started when I copied some files from a Windows 98
and a Linux computer over the network. The fix seems to be to copy the
directory and spend an hour or two deleteing the old directory bit by bit.
Pain, I had to do this several times so far when restructuring my data.

I'm just guessing, but I installed a HD from my XP machine with all files
intact.
There was now a New numeric [12-0-3-67-hy-56] etc... user in the owners..
The
fix was to delete that numeric user and take the permissions the way I
showed
you.
--
more pix @ http://members.toast.net/cbminfo/index.html



New machine from Dell with OEM

Taken ownership and permissions, which I should have anyway because I copied
files from Network. If I didn't have permissions I wouldn't be able to
delete file when I enter subdirectories.
 
J

John Stubbings

Andrew McLaren said:
What is the exact text of the error message you get, if you do a "rd /s"
on the tree?


Sorry can't give you exact text I managed to delete files in all cases, it
just took ages going into subdirectories. The error message said ' Cannot
delete directory as it contains files' or something similar, same as when
not using /s switch, but most directories it deleted fine just a few it
doesn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top