I still use this script for quick deletion of empty folders. It works well, but it can not work always. I found out it does not work if the space is in path of initial directory. The "Set the path to the existing directory!" is shown. I run it from TC Start menu where Command is vbs file and Parameters is %P. Can you help me with it?I would like to request in vbs:Code:
'————————————————————— VBS —————————————————————' Recursive deletion of empty subdirectories' Parameter: "<folder path>" (for example, "%P")'———————————————————————————————————————————————Option Explicit: Dim Dir, FSO, Col, D, c, MsgDir = WSH.Arguments(0)Const Title = " Deleting empty subfolders"Set FSO = CreateObject("Scripting.FileSystemObject")Set Col = CreateObject("System.Collections.ArrayList")If Not FSO.FolderExists("\\?\" & Dir) Then _MsgBox "Set the path to the existing directory!", 262192, Title: QuitIf MsgBox("Execute in """ & Dir & """?", 262180, Title) = 7 Then QuitRecursion FSO.GetFolder("\\?\" & Dir)Col.Sort : Col.ReverseFor Each D in Col Set D = FSO.GetFolder(D) If D.SubFolders.Count + D.Files.Count = 0 Then c = c + 1: D.Delete 1NextIf c Then Msg = " Done!" & vbLf &_" Count of deleted: " & c Else Msg = "No empty subfolders found."MsgBox Msg, 262208, Title: QuitSub Quit : Set FSO = Nothing : Set Col = Nothing : WSH.Quit : End SubSub Recursion(oDir) For Each D in oDir.SubFolders If D.SubFolders.Count Then Col.Add D.Path :_ Recursion D Else If D.Files.Count = 0 Then c = c + 1: D.Delete 1 NextEnd Sub
Statistics: Posted by oko — 2024-01-31, 21:01 UTC