Windows Vista Forums

Detect files in a folder...

  1. #1


    Phil Strack Guest

    Detect files in a folder...

    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





      My System SpecsSystem Spec

  2. #2


    Pegasus \(MVP\) Guest

    Re: Detect files in a folder...


    "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



      My System SpecsSystem Spec

  3. #3


    Phil Strack Guest

    Re: Detect files in a folder...

    Thanks...so simple I clearly overlooked/overthought it.

    "Pegasus (MVP)" <I.can@xxxxxx> wrote in message
    news:%238VQrGdGJHA.456@xxxxxx

    >
    > "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
    >
    >


      My System SpecsSystem Spec

Detect files in a folder...

Similar Threads
Thread Thread Starter Forum Replies Last Post
Solved Trying to save to my documents folder rather than the temp internet files folder DJC2962 Browsers & Mail 10 22 Oct 2009
Can not detect new files with name in multi-byte languages eruisi Live Folder Share 0 22 Nov 2007
Problem deleting vista RC windows folder and program files folder Rob Holmes Vista account administration 0 08 Aug 2007
deleting vista RC windows folder and program files folder Rob Holmes Vista file management 0 06 Aug 2007
Re: Copying CD files to folder, then copy folder to another hard drive, explorer hangs zoner@cox.nospam.net Vista file management 0 31 Mar 2007