| Filesystem: VBscript to enumerate all subfolders (recursive) of a given folder | Active Directory: VBscript to enumerate the last logon of all AD users and a lot of user attributes V2 |
Mar 052010
Here’s the second script of today.
It is a mutation of the previous script.
Added is a depth limit, this is done by a second argument of the subroutine.
The subroutine needs two arguments: the path of the folder and the depth level.
The path can be local (“c:\temp”) or an UNC path like “\\server\test”.
Follow the next steps to run the script (admin rights needed on the folder you want to enumerate):
- open your favorite text editor
- copy and paste the script into the editor
- change the path of the folder to your folder path
- change the depth value to your depth value (current value = 2)
- save the script (for example c:\temp\enumeratesubfolderslevel.vbs)
- open a command prompt
- go to “c:\temp”
- give “cscript enumeratesubfolderslevel.vbs” (without quotes) and enter
The script:
' Name : enumeratesubfolderslevel.vbs
' Description : script to enumerate the subfolders (recursive) with depth limit
' Author : dirk adamsky - deludi bv
' Version : 1.01 corrected small counter error
' Date : 05-03-2010
' Level : Intermediate
ViewSubFolders "c:\temp", 2
Sub ViewSubFolders(strFolder, strMaxLevel)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
If strMaxlevel >= 1 Then
For Each SubFolder in objFolder.SubFolders
Wscript.Echo SubFolder.Path
ViewSubFolders SubFolder, (strMaxlevel - 1)
Next
End If
Set objFolder = Nothing
Set objFSO = Nothing
End Sub
When you have problems/questions please make a reply, when you like the script please rate it with the star rating below.
Happy scripting.
Best regards,
Dirk Adamsky – Deludi BV
VN:F [1.9.3_1094]
VN:F [1.9.3_1094]
Posted by dirk adamsky at 11:28
Tagged with: attribute, command prompt, computer, cscript, depth, enumerate, files, filesystem object, limit, list, objFSO, recursion, subfolders, unc, vb, vbs, vbscript





Recent Comments