[VBS] Count and Retrieve Folder Name

Solved
Allizou Posted messages 35 Registration date   Status Member Last intervention   -  
Allizou Posted messages 35 Registration date   Status Member Last intervention   -
Hello,
As a novice in VB Script, I need to count the number of folders and retrieve their names from a given directory. After fruitless searches on the internet, I found how to count and retrieve the names of files, but nothing regarding folders.
I searched through these links:
https://www.commentcamarche.net/contents/1168-objet-folder
https://www.commentcamarche.net/contents/1174-objet-filesystemobject-fso
Without much success... If anyone has a lead... Thank you in advance!
Best regards, Allizou.

Configuration: Windows Vista / Firefox 5.0

1 answer

  1. Allizou Posted messages 35 Registration date   Status Member Last intervention   9
     
    I finally found it after searching some more.

    Here is a function that goes through all the subfolders of a directory and returns their names:

     Dim stRep 'Name of the directory to explore Dim oFSO,oFld Set oFSO = CreateObject("Scripting.FileSystemObject") stRep = "C:\Program Files\Common Files" If oFSO.FolderExists(stRep) Then For each oFld in oFSO.GetFolder(stRep).SubFolders Wscript.Echo oFld.Name Next End If 


    To count them, just add an increment.
    Here is the link, everything is there:
    https://vb.developpez.com/faq/vbs

    Good luck everyone.
    4