Click here to Skip to main content
15,886,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there !

First off I'd like to say I'm sorry for asking for help, normally I would deal with this stuff myself, but since I'm all new to VBS this has been a pain for me !

Okay, I work for a company with a DFSshare and we have had problems when the share looks empty.
I have to make a VBScript to look for empty folders.
"RootFolder" > "A lot of folders in here representing customers" > "This folder cannot be empty"

This is how far I got, but all it does is give me a glimps ):
MSIL
Set FSO = CreateObject("Scripting.FileSystemObject")
'Define Root folder
ShowSubfolders FSO.GetFolder("C:\DFSRoots")
Sub ShowSubFolders(Folder)
    'For Each folder, create another For Each instance
    For Each Subfolder in Folder.SubFolders
        For Each subdir in Subfolder.SubFolders
        'Create Status to contain the result
        Status = 0
        'Grab path of the folder to check for empty...ness
            set folder = FSO.GetFolder(subdir.Path)
            'If subdir.Path contains no files, nor folders throw Status 2, otherwise Status 0
            If folder.Files.Count + folder.SubFolders.Count = 0 Then
                Status = 2
                WScript.Echo Status
            Else
                Status = 0
                WScript.Echo Status
            End If
        Next
    Next
End Sub


It would be awesome with a whole code snippet, but a wift in the right direction is also okay :)
Thanks !
Posted
Updated 24-Aug-10 14:18pm
v2
Comments
Dalek Dave 24-Aug-10 20:19pm    
Edited for Grammar and Spelling.

1 solution

Seems that the recursion [^] is missing in your method?

Cheers
Uwe
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900