Emmanuel
Master Tech
- Local time
- Today, 09:11
- Joined
- Sep 4, 2002
- Messages
- 88
Hi guys,
I have the code below that a friend gave me, but I need to change it to check multiple folders. Can you please provide me with some help? I need to do something like an elseif so it can check folders:
"\\tbstp\R2W\Admin\Watch"
"\\tbstp\R2W\Admin\Watch2"
"\\tbstp\R2W\Admin\Watch3"
'************* Code starts ******************
Option Explicit
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Function FolderEmpty(strFolderPathName)
Dim oFiles, oFile, oFolder, oSubFolders, oSubFolder
Dim blnFileFound : blnFileFound = False
Set oFolder = oFS.GetFolder(strFolderPathName)
Set oFiles = oFolder.Files
If oFiles.Count > 0 Then
FolderEmpty = False
Exit Function
End If
Set oSubFolders = oFolder.SubFolders
For Each oSubFolder In oSubFolders
If Not FolderEmpty(oSubFolder.Path) Then
FolderEmpty = False
Exit Function
End If
Next
FolderEmpty = True
End Function
Dim strFolderPathName : strFolderPathName = "\\tbstp\R2W\Admin\Watch"
If not FolderEmpty(strFolderPathName) Then
MsgBox "Directory " & strFolderPathName & " is Empty."
Else
MsgBox "Directory " & strFolderPathName & " has files."
End If
'************** Code ends *************************
Thanks,
WebManny
I have the code below that a friend gave me, but I need to change it to check multiple folders. Can you please provide me with some help? I need to do something like an elseif so it can check folders:
"\\tbstp\R2W\Admin\Watch"
"\\tbstp\R2W\Admin\Watch2"
"\\tbstp\R2W\Admin\Watch3"
'************* Code starts ******************
Option Explicit
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Function FolderEmpty(strFolderPathName)
Dim oFiles, oFile, oFolder, oSubFolders, oSubFolder
Dim blnFileFound : blnFileFound = False
Set oFolder = oFS.GetFolder(strFolderPathName)
Set oFiles = oFolder.Files
If oFiles.Count > 0 Then
FolderEmpty = False
Exit Function
End If
Set oSubFolders = oFolder.SubFolders
For Each oSubFolder In oSubFolders
If Not FolderEmpty(oSubFolder.Path) Then
FolderEmpty = False
Exit Function
End If
Next
FolderEmpty = True
End Function
Dim strFolderPathName : strFolderPathName = "\\tbstp\R2W\Admin\Watch"
If not FolderEmpty(strFolderPathName) Then
MsgBox "Directory " & strFolderPathName & " is Empty."
Else
MsgBox "Directory " & strFolderPathName & " has files."
End If
'************** Code ends *************************
Thanks,
WebManny