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 - Looping through directory

Reply
 
Old 01-07-2009   #1 (permalink)
D.P. Roberts


 
 

Looping through directory

I have a directory named USERS which contains about 100 unique user folders.
Each user folder contains a folder named RECYCLER and I would like to
generate a report of the size of each user's RECYCLER folder. I already know
how to use vbs to lookup a folder size and write the results to a log file.
But what I don't know how to do is loop through the directories in the first
place. Anyone know how to do this?

Thanks!


My System SpecsSystem Spec
Old 01-07-2009   #2 (permalink)
Paul Randall


 
 

Re: Looping through directory


"D.P. Roberts" <dproberts@xxxxxx> wrote in message
news:eeEfZLScJHA.1328@xxxxxx
Quote:

>I have a directory named USERS which contains about 100 unique user
>folders. Each user folder contains a folder named RECYCLER and I would like
>to generate a report of the size of each user's RECYCLER folder. I already
>know how to use vbs to lookup a folder size and write the results to a log
>file. But what I don't know how to do is loop through the directories in
>the first place. Anyone know how to do this?
>
> Thanks!
Sample code from the scripting help file SCRIPT56.CHM:

Function ShowFolderList(folderspec)
Dim fso, f, f1, s, sf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 in sf
s = s & f1.name
s = s & "<BR>"
Next
ShowFolderList = s
End Function

-Paul Randall


My System SpecsSystem Spec
Old 01-08-2009   #3 (permalink)
David Glienna


 
 

Re: Looping through directory

You might want to take a look at Powershell 2.0 CTP. It lets you use simple
DOS-like commands to control the framework.

- David


"Paul Randall" <paulr90@xxxxxx> wrote in message
news:egTvbzTcJHA.1732@xxxxxx
Quote:

>
> "D.P. Roberts" <dproberts@xxxxxx> wrote in message
> news:eeEfZLScJHA.1328@xxxxxx
Quote:

>>I have a directory named USERS which contains about 100 unique user
>>folders. Each user folder contains a folder named RECYCLER and I would
>>like to generate a report of the size of each user's RECYCLER folder. I
>>already know how to use vbs to lookup a folder size and write the results
>>to a log file. But what I don't know how to do is loop through the
>>directories in the first place. Anyone know how to do this?
>>
>> Thanks!
>
> Sample code from the scripting help file SCRIPT56.CHM:
>
> Function ShowFolderList(folderspec)
> Dim fso, f, f1, s, sf
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFolder(folderspec)
> Set sf = f.SubFolders
> For Each f1 in sf
> s = s & f1.name
> s = s & "<BR>"
> Next
> ShowFolderList = s
> End Function
>
> -Paul Randall
>
My System SpecsSystem Spec
Old 01-08-2009   #4 (permalink)
D.P. Roberts


 
 

Re: Looping through directory

Thank you very much. This was most helpful and I appreciate your taking the
time to answer my question.

"Paul Randall" <paulr90@xxxxxx> wrote in message
news:egTvbzTcJHA.1732@xxxxxx
Quote:

>
> "D.P. Roberts" <dproberts@xxxxxx> wrote in message
> news:eeEfZLScJHA.1328@xxxxxx
Quote:

>>I have a directory named USERS which contains about 100 unique user
>>folders. Each user folder contains a folder named RECYCLER and I would
>>like to generate a report of the size of each user's RECYCLER folder. I
>>already know how to use vbs to lookup a folder size and write the results
>>to a log file. But what I don't know how to do is loop through the
>>directories in the first place. Anyone know how to do this?
>>
>> Thanks!
>
> Sample code from the scripting help file SCRIPT56.CHM:
>
> Function ShowFolderList(folderspec)
> Dim fso, f, f1, s, sf
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFolder(folderspec)
> Set sf = f.SubFolders
> For Each f1 in sf
> s = s & f1.name
> s = s & "<BR>"
> Next
> ShowFolderList = s
> End Function
>
> -Paul Randall
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
err object and looping VB Script
Looping through each file in a directory: Powershell noob question PowerShell
Help looping a script PowerShell
AD Changes and Looping PowerShell
Looping at start Vista installation & setup


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