Link to home
Start Free TrialLog in
Avatar of sdc248
sdc248Flag for United States of America

asked on

Cannot delete a folder and its sub-folders

Hi:

One of the apps I use created a folder and then countless sub folders with the same name, and I cannot find a way to delete them.

My folders look like: C:\ParentFolder\folderToDel\folderToDel\folderToDel.......\folderToDel

From Windows Explorer, I go to C:\ParentFolder, click on the folder and hit delete, 'yes', 'Yes to All', and I get "Cannot remove folder xxx: the directory is not empty" error message.
I tried drill down to the last folder I can get to and hit delete, nothing happened.

I also tried remove them from the command prompt, but got "The system cannot find the patch specified." error.

Please help. I use Windows XP.
Avatar of WayneATaylor
WayneATaylor
Flag of United Kingdom of Great Britain and Northern Ireland image

My guess would be there are hidden or system files in the directories or if it's an ntfs drive it might be a permissions issue.

From a file window go to the folder options setting and turn on viewing hidden files and also turn off hide system files.   That should then show files.

If it's a permissions thing, you might need to go to the top level and right click/properties then reset permissions and sort to also reset child folders

Wayne
Avatar of sdc248

ASKER

Tried the folder options.  Still not seeing any hidden (system) files.

The Permissions button in Properties is grey-out for me.
Avatar of ola_erik
ola_erik

Hmm, I don't remember the phrasing of specific error messages but here is something:

restart your machine and try again

you should be able to delete directories in spite of them having files in them, sometimes an application has locked an open file. If it's extra cumbersome, you have an autostarted app or service running from your folders and the files themselves are hidden, as previously mentioned.

get "process explorer"
go to "find" in the menu
type some unique part of the folder name
if a file in that path is open it will list
you can see what process is blocking
kill that process in process exlorer or taskmanager
delete the folders

contemplate uninstalling the process/ app/ service now referencing an non-existant file

------------

you might have some damaged files/ folders
you might try run chkdsk to find out/ repair
Avatar of Dan Craciun
You've run into a large path (over 255 characters) which gives Windows problems.
It has various solutions:
- Map a drive to a folder in the structure of the path and delete from that point on, then delete the mapping and delete the rest of the folder
- rename each directory to a single character until the path is short enough to delete
- cut the folder in explorer and then paste it into the recycle bin
- use robocopy (solution taken from here):

To delete the directory tree starting at c:\subdir\more\offending_dir:

cd c:\subdir\more to cd into its parent directory.
mkdir empty to create an empty directory.
robocopy empty offending_dir /mir to mirror the empty directory into the offending one.
After some waiting you're done! Finish it up with:
rmdir offending_dir to get rid of the now empty offending directory and
rmdir empty to get rid of your intermediate empty directory.

HTH,
Dan
It is a typical disk error.

Type the procedures listed in the link below to perform a scheduled chkdsk.

http://www.computerstepbystep.com/chkdsk_windows_xp.html
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It looks to be the character limit on Windows

basically when your path C:\whatever\whatever\whatever reaches more than 255 on xp and 270 in windows 7? windows cannot recognise these locations and therefore cannot delete etc.

it's stupid but the best and easiest method is to go to folder 1 and rename it to the letter "a" or "1" something that is 1 character long

so where your initial folder structure was

C:\whatever\
                     whatever
                                    whatever
                                                   whatever

etc.. now you will have

C:\1
      1
        1
          1
            1
               1

this will take your folder names down massively and if you keep doing this (starting at the top folder) and continuing down to the bottom. eventually (unless you have more than 255 folders) you should be able to successfully delete your entire subdirectory
it's slow, it's paainful, but DAMMIT it works! haha

good luck
Avatar of sdc248

ASKER

Thank you all for your help. I tried David's solution and it worked.