How to count Number of sub folders and print Names

How to get sub folder count and print folder names using below VBScript,In order to count number of subfolders we need to use File System Object(FSO) .Please check the below code(VB Script) to print number of sub folders as well as Count number of Sub folders.



VB Script:

Dim Obj,Obj1,Obj2,Fold_names

Set Obj = CreateObject("Scripting.FileSystemObject")

'Creating a file system object

    Set Obj1 = Obj.GetFolder("D:\Manual_Testing\Manual_Projects")

    Set Obj2 = Obj1.SubFolders

    msgbox Obj2.Count 'displaying count of sub-folders

    For Each Fold_Iteam in Obj2

        Fold_names = Fold_names& Fold_Iteam.name &vbnewline

Next

msgbox Fold_names


No comments:

Post a Comment