delete folder, subfolders, files in cmd command - get error name.txt too long

i have a folder that was robocopy /mir and it created lots of sub folders and files

i am trying to delete it with cmd commands

del c:\clients\users /s /f /q

it looks like it is rolling along and then stops with:
clientname.txt is too long

how can i get this to delete?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Unfortunately the path and filename is too long to process, there are two things you can try to do:

Option 1: Share Deep.

find a directory that's quite deep down that you can still access, share the folder, then map a drive to the same share, and see if you can delete the remainder through DOS or Windows Explorer.  This is not guranteed to work unfortunately, but it's worth a shot.

Option 2: Rename Rename Rename

Rename folders above which will reduce the path length.  For example, if your folder structure is like this:

D:\This is a\stupidly long\folder name and\I should be\castrated\as a result\blahblah\gibber\file.txt

Then rename each folder so that the whole path is shorter:


You will then be able to rmdir the folder.
Hendrik WieseInformation Security ManagerCommented:
Use the following to remove the Folder with all Sub Folders and Files:

The following will delete the entire users folder with everything in it.
rmdir /s /q "C:\clients\users"
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Steve KnightIT ConsultancyCommented:
Good point on the share to make path shorter.... another way is to use

I don't know off hand if this is present still on 2008 but if not do it from a mapped drive on an XP workstation, or from a 2003 server.

Start cmd.exe (as administrator if on the 2008 box).
Now paths are in short 8.3 name format.
cd \clients\users
rd /q /s c:\clients\users

You can use
dir /x

to see the short names of the dirs to CD into to make the paths shorter.
i think is not present in 2008.

how about just Selecting the root folder and SHift Del ? if the idea is just to del the folders, just a thought.
Steve KnightIT ConsultancyCommented:
I think the problem here is that the files have been created end up breaking limits on the length of full path / filename.  Mapping a drive part what down the tree of the directory, or renaming like has been suggested effectively reduces the path, as does using 8.3 names for long ones.
webdottAuthor Commented:
thanks - that is a nice tool!
webdottAuthor Commented:
Bill PrewCommented:
Great, glad that proved to be useful.

All Courses

From novice to tech pro — start learning today.