"Phil Strack" <p.strack@xxxxxx> wrote in message
news:ORVED0cGJHA.3884@xxxxxx
> Hi All-
> I have a script that as part of one of its validation routines needs to
> verify that a specific folder has no files in it. The problem is the
> folder can and will likely contain subfolders within it. (which is
> expected and okay) If the routine detects files at the root if the
> specific folder I halt any further processing.
>
> I've tried a variety of ways using WMI queries for resultclass
> CIM_DataFile and FileSystemObject to achieve my desired result and so far
> have been unsuccessful in solving my little problem. This is running on a
> Windows 2003 R2 Standard Server environment.
>
> Thanks in advanced for any assistance offered.
>
> -Phil You could use this code:
sFolder = "d:\Test"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFiles = oFSO.GetFolder(sFolder).Files
WScript.Echo "File count = " & oFiles.count