We have a little problem here.
We have a share with the backup of all the server's offices, Its a really big share with more than 8.000.000 files.
Our users usually give long names to the folders they create, and then make subfolders (long too) and more subfolders... and more suboflders....
We have a new share with more capacity, and with a simpe robocopy bat we copied all the files and folders (some give problems, but we manually copied them)
But the problem is deleting them. del command didnt work well when so long paths, neirder rmdir... I'm tried some commanders, but no luck.
Can u recommend me any tool that can delete recursively or able to delete 255+ paths?
Edited: The SO on background of the share it's NetApp OS. But I can access it from Windows Servers. 2000 and 2003
Thanks.
Not perfect solution but that works
Here's the script on Windows Scripting I do to solve the problem. It isn't perfect but if anyone has the same problem can use it.
Option Explicit
DIM strFolder
DIM objFSO
' ************************************************************
' Setup
' ************************************************************
' Folder to delete files from (files will also be deleted from subfolders)
strFolder = "Z:\del"
' ************************************************************
set objFSO = createobject("Scripting.FileSystemObject")
Wscript.echo "Processing " & strFolder
RecursiveDeleteByExtension strFolder
wscript.echo "Finished"
sub RecursiveDeleteByExtension(byval strDirectory)
DIM objFolder, objSubFolder, objFile, Tmp, Indice
set objFolder = objFSO.GetFolder(strDirectory)
Wscript.echo "Processing " & strDirectory
for each objFile in objFolder.Files
WScript.echo "Deleting:" & objFile.Path
objFile.Delete
next
Indice = 0
For each objSubFolder in objFolder.SubFolders
If Len (objSubFolder.Name) > 5 Then
Indice = Indice + 1
objSubFolder.Move(objFolder.Path & "\" & Indice & ".t")
End if
Next
for each objSubFolder in objFolder.SubFolders
RecursiveDeleteByExtension objSubFolder.Path
Next
objFSO.DeleteFolder(strDirectory)
end sub
What this script do, recursively, is changing a very long path like \bla...\bla...\bla...\bla... to a much more shorter \1\2\1\2\ and after the renaming in the end of each recursion, it deletes the object folder (who's empty, btw).
It worker extremely well for me, even so we found full paths near 200 chars (imagine with before the script).
This is a program
dot_deltree.cs
in C# which deletes directory trees of any depth. It works by first moving too deep directories to random name in the most shallow directory.Compiled using Mono C# compiler using
gmcs dot_deltree.cs
for .NET 2.0 is here (4kb).try for /f "delims=" %a in ('dir /ad /b') do rm /s /q "%a" - it will recursively and without asking delete all the subdirectories of the current directory listed in dir /ad /b output
If this share is the only thing on a partition then it would be easiest to just reformat it.
If there's something worth saving on the partition, then just copy it somewhere, reformat and copy it back.
Try using "deltree". I'm on only linux right now, but I recommend doing a "deltree /?" first!
Have you tried WinDirStat I'm not sure about the 255 limit as it issues windows commands to do the deleting but it might help you sort out the mess easier.
Very useful tool otherwise
What happens if you use robocopy's /move option? This will delete the files from the source after copying.
What if you used
ROBOCOPY
with the/MIR
flag to mirror an empty folder overtop the unwanted files? If it's smart enough to copy files with long names, it should be smart enough to delete them.Althoguh it's possible that this won't get any farther than Chris' suggestion.