Aussie owned and operated, with 23+ years of industry experience, Gold Coast InfoTech is delighted to support all of your business technology requirements.

Gallery

Contacts

success@goldcoastinfotech.com.au

1800 291 071

KBArticles Scripts, Commands, Registry Uncategorized

SCRIPT: check if folder is empty

‘vbscript
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 strFolderPathName1 : strFolderPathName1 = “file://server/c$/folder
If FolderEmpty(strFolderPathName1) Then
 MsgBox “the folder ” & strFolderPathName1 & ” is empty”
Else
 MsgBox “the folder ” & strFolderPathName1 & ” is not empty”
End If

Author

Customer

Leave a comment

Your email address will not be published. Required fields are marked *