I have a pretty weird problem with a folder structure that was created by my ant build...it created a folder structure such that C:helper/class/helper/class/helper/class and goes on for a very long time.
I was wondering if there was some script that I could use to delete these folders using cmd on Windows 7.
I have already tried:
rmdir /s /q
along with trying to use :
robocopy "C:helper/class/helper/class/helper/class" C:Test
But still I got no luck...
Does anyone have any suggestions or script that I could use for a bat file to recursively delete this structure?
Solving "Too Long" Filename Errors The trick is to auto-generate a shorter filename and use that. Open a command prompt in the directory where the file is located. Use a DOS command to get the short filename in the 8.3 filename format. Now, use the DEL command in DOS for the file to delete the file.
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.
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.
I have had much more success with the built-in del command in Windows 7.
I have seen del /s /q
work in situations where rmdir /s /q
does not.
i've done it with "FastCopy ver3.13"
source : path of to long directory
dest: c:\x\
operation mode (drop down): Delete all (delete all files / dirs by force)
executed it 3 times, and my problem was solved. robocopy, 7zip does not work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With