Solved

Cannot delete a folder and its sub-folders

Posted on 2014-02-04
8
494 Views
Last Modified: 2014-02-26
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.
0
Comment
Question by:sdc248
8 Comments
 
LVL 10

Expert Comment

by:WayneATaylor
ID: 39834181
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
0
 

Author Comment

by:sdc248
ID: 39834248
Tried the folder options.  Still not seeing any hidden (system) files.

The Permissions button in Properties is grey-out for me.
0
 
LVL 3

Expert Comment

by:ola_erik
ID: 39834258
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
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39834356
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
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 41

Expert Comment

by:Jackie Man
ID: 39834388
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
0
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 39834556
from a command prompt
rd \\.\C:\areallylongfilename /s/q  where C is the drive letter and \reallylongfilename is the top level directory that you want to remove

if there are files you may have to

del \\.\c:\areallylongfilename /s/q

note that these are \\ and not //'s

Total Commander also has support for really long filenames
0
 
LVL 10

Expert Comment

by:Scott Thomson
ID: 39887998
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
0
 

Author Comment

by:sdc248
ID: 39888946
Thank you all for your help. I tried David's solution and it worked.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
Ok I have been working on this for some time having learned and gained certification in XenDesktop 4 along came version 5 which was released last month. Since then I have been working to deploy XenDesktop 5 in a small environment with only 2 virt…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now