Find Empty Folders
- From: "Yogi_Bear_79" <nospam@xxxxxxxxxxx>
- Date: Tue, 14 Nov 2006 15:08:12 -0500
I have this script that is supposed to find empty folders and write them to
a text file. It works only partially. It actually accurately finds some
empty folders, and others it misses entirely. It also lists some but not all
folders that are empty of files but contain subfolders.
Basically I want to clean up my MP3 drive. WMP leave a lot of garbage
folders. SO The plan is to write to file any folder that is empty or better
yet any folder that doesn't contain an .mp3 or m3u file
Dim oShell, oFolder, oFolderItem, fso, selected, howbad, ColonPos
Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Shell.Application")
On Error Resume Next
Set oFolder = oShell.BrowseForFolder(0, "Select where to search",&H0011 ,
ssfDRIVES)
Set oFolderItem = oFolder.Items.Item
Set selected=fso.GetFolder(oFolderItem.Path)
'
howbad = err.number
If howbad <> 0 Then
If howbad = 424 then
oFolder = Null
else
ColonPos = InStr(oFolder.Title, ":")
If ColonPos > 0 Then
selected = Mid(oFolder.Title, ColonPos - 1, 2) & "\"
End If
End If
End If
'
If IsNull(oFolder) Then MsgBox "No valid folder or drive
selected":WScript.Quit
'Set f=fso.CreateTextFile(fso.GetSpecialFolder(0)&"\desktop\Empties.txt")
Set f=fso.CreateTextFile("c:\Empties.txt")
f.WriteLine selected&" contains the following folders that are devoid of
files"
f.WriteLine " "
'
If selected.SubFolders.Count<>0 Then
WorkWithSubFolders selected
Else
If selected.files.Count=0 Then f.WriteLine selected
End If
'
Sub WorkWithSubFolders(selected)
Dim MoreFolders, TempFolder
If selected.files.Count=0 Then f.WriteLine selected
Set MoreFolders = selected.SubFolders
For Each TempFolder In MoreFolders
WorkWithSubFolders TempFolder
Next
End Sub
Set fso = Nothing
Set oShell = Nothing
.
- Follow-Ups:
- Re: Find Empty Folders
- From: Walter Zackery
- Re: Find Empty Folders
- Prev by Date: Re: SCript to delete old files
- Next by Date: ActiveX Parameter(s)
- Previous by thread: Re: Finding Control on HTML page using VBScript
- Next by thread: Re: Find Empty Folders
- Index(es):
Relevant Pages
|