Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Detect files in a folder...

Reply
 
Old 09-18-2008   #1 (permalink)
Phil Strack


 
 

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
Old 09-18-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

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
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
Old 09-19-2008   #3 (permalink)
Phil Strack


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46