/ VBScript for Windows
Let's say you want to write a script wich deletes specific folders in a directory structure, but only these folders wich are empty.
This script checks to see if a specific folder is empty and it can easely be integrated in a recursive function wich iterates over several folders.
Dim objFSO, objFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\FolderName\") Then
Set objFolder = objFSO.GetFolder("C:\FolderName\")
If objFolder.Files.Count = 0 And objFolder.SubFolders.Count = 0 Then
MsgBox "The folder is empty"
MsgBox "The folder contains files and/or subfolders"
Here we use the FileSystem object to 'bind' to a specific folder called FolderName in the root of the C-drive.
23-06-2009 by Thomas Møller Nexø
We then use this folders files and subfolders properties to dertermine whether the folder is actually empty or contain files or subfolders.
Unique visits since publich date 10432
Comment on this article