![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | Re: Detect files in a folder... "Phil Strack" <p.strack@xxxxxx> wrote in message news:ORVED0cGJHA.3884@xxxxxx Quote: > 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 sFolder = "d:\Test" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFiles = oFSO.GetFolder(sFolder).Files WScript.Echo "File count = " & oFiles.count |
My System Specs![]() |
| | #3 (permalink) |
| | 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 Quote: > > "Phil Strack" <p.strack@xxxxxx> wrote in message > news:ORVED0cGJHA.3884@xxxxxx Quote: >> 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 Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Program Files folder switched to Pictures Folder type... | Vista file management | |||
| Problem deleting vista RC windows folder and program files folder | Vista account administration | |||
| deleting vista RC windows folder and program files folder | Vista file management | |||
| Re: Copying CD files to folder, then copy folder to another hard drive, explorer hangs | Vista file management | |||