Click here to Skip to main content
11,805,316 members (66,022 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VBScript
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 ):
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
                Status = 0
                WScript.Echo Status
            End If
End Sub

It would be awesome with a whole code snippet, but a wift in the right direction is also okay Smile | :)
Thanks !
Posted 22-Aug-10 20:25pm
Edited 24-Aug-10 14:18pm
Dalek Dave433.2K
Dalek Dave at 24-Aug-10 20:19pm
Edited for Grammar and Spelling.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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


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

  Print Answers RSS
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 25 Aug 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100