Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Delete Empty Directories
#DefineFunction DeleteEmptyDirectories(Root) ; ; Examine every directory under the root. ; Delete them if they are empty. ; Return the number of items in ROOT ; DirList = DirItemize(StrCat(Root,"\*.*")) Total = 0 while @TRUE NextDir = ItemExtract(1,DirList,@TAB) if NextDir == "" then break DirList = ItemRemove(1,DirList,@TAB) NextDir = StrCat(Root,"\",NextDir) Count = DeleteEmptyDirectories(NextDir) if Count == 0 DirRemove(NextDir) else Total = Total + Count + 1 endif endwhile Count = ItemCount(FileItemize(StrCat(Root,"\*.*")),@TAB) Total = Total + Count return Total #EndFunction ;----------------------------------------------------------- ; Test the UDF ;----------------------------------------------------------- TestDir = "C:\Temp\Test" x = DeleteEmptyDirectories(TestDir) if x == 0 then DirRemove(TestDir)
Article ID: W15289
File Created: 2002:09:05:13:51:04
Last Updated: 2002:09:05:13:51:04