I wrote this program to scan thru a drive and delete all the empty SubDirectories.
Hope some one can use this.
Bill
/* Recurse_Delete_Empty_Dirs.EBA
Written by Bill Haesslein
This program will process a drive and delete
empty directories
*/
DEF count:INT
DEF Deleted, NotDeleted:int
DEF Drive:string
Deleted = 0
NotDeleted = 0
Count = 0
OPENCONSOLE
'recursively print all directories
PRINT "Enter Drive:",
INPUT Drive
If Drive = "" then Goto Done
count = deletedir(Drive + ":\\")
PRINT count, "Files"
PRINT Deleted, "Deleted"
PRINT NotDeleted, "Not Deleted"
PRINT "Press Any Key"
DO:UNTIL INKEY$ <> ""
Label Done:
CLOSECONSOLE
END
SUB deletedir(path:STRING),INT
DEF count:INT
DEF dir,attrib:INT
DEF filename:STRING
DEF fullname:STRING
count = 0
IF ucase$(path) = "C:\\ZZZZ\\#MPDA\\" THEN RETURN count
dir = FINDOPEN(path + "*.*")
IF(dir)
DO
filename = FINDNEXT(dir,attrib)
IF len(filename)
IF attrib & @FILE_DIRECTORY
IF(filename <> ".") & (filename <> "..")
' PRINT path + "[" + filename + "]"
fullname = path + filename + "\\"
count = count + deletedir(fullname)
ENDIF
ELSE
count = count + 1
ENDIF
ENDIF
UNTIL filename = ""
FINDCLOSE dir
' PRINT path, count
if (count = 0)
R=RemoveDir(Path)
if (R=0)
NotDeleted += 1
print Path, " Not Deleted"
else
Deleted += 1
print Path, " Deleted ***"
endif
endif
ENDIF
RETURN count
ENDSUB