Deleting a very long path in a directory Deleting a very long path in a directory windows windows

Deleting a very long path in a directory


Try

 robocopy /e /b /purge c:\empty c:\folder-to-delete


del and rmdir commands can't delete folders with long names. But 7-Zip can! Right click on a folder which should be deleted. Select "Add to Archive" in 7-Zip context menu and set "Delete files after compression" option in "Add to Archive" 7-Zip dialog. 7-Zip create archive files and delete folder with long paths! After that you can delete archive file.

enter image description here


The problem may be due to a limit on how long paths may be in Windows itself. There's a limit of around 1551 characters. It's very easy in a Java project (or even a C# .NET project) to create these very long paths. Especially if you're putting your project under something like C:\Documents and Settings\Baron Van Hushoven\Documents\Projects\My Project -- 74 characters long).

If this is your issue, you may be forced to use to the Subst command. This allows you to create a drive letter that represent another path, then you can use that drive letter to help create a shorter path.

C:\> subst x: "C:\Documents and Settings\Baron Van Hushoven\Documents\Projects\My Project"

Now, you can use X: as the root of your project which will shorten the paths you're attempting to delete by 74 characters which may just be enough for Windows to be able to access these files.


1. The limit is actually 260, but once you put in C:\, you're pretty much down to 255. Ironically, NTFS can handle extremely long paths of around 32K, and Windows can also handle these long names too. You might be able to prefix the path with "\\?\" as in\?\C:\Documents ...` However, I don't believe that works in Windows Explorer or the Command Line Console.