By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!del /s /e /x /y c:\targetdir\con.*
@Echo Off
SetLocal
Set Root="%@UnQuoteS[%1]"
Iff %Root == "" Then
@EchoErr Error: Missing name of directory to be processed.
EndLocal
Quit 8
EndIff
Iff NOT EXIST %Root Then
@EchoErr Error: A directory named %Root does not exist!
EndLocal
Quit 16
EndIff
Iff NOT IsDir %Root Then
@EchoErr Error: File-system object %Root is not a directory!
EndLocal
Quit 32
EndIff
GoSub ProcessDirectory %Root
Gosub RemoveDirectory %Root
EndLocal
Quit 0
:ProcessDirectory [Directory]
Set NotEmpty=
For /D %ThisDir in ("%@UnQuoteS[%Directory]\*") Do (
Set Empty=Y
Gosub ProcessDirectory "%ThisDir"
Gosub RemoveDirectory "%ThisDir"
)
Set Empty=
If "%NotEmpty" == "" ^
If %@Files["%Directory\*",-D] == 0 ^
Set Empty=Y
Return
:RemoveDirectory [Directory]
Iff "%Empty" == "Y" Then
Attrib -R /D %Directory >NUL:
RD %Directory >NUL:
Iff %_? != 0 Then
@EchoErr Note: Failed to remove apparently empty directory %Directory
Set NotEmpty=Y
EndIff
Else
Set NotEmpty=Y
EndIff
Return
(By the way, what does the acronym "AFAIK" stand for?)