gabrielaz
asked on
vbscript to list folder names
hello experts,
looking for a script htat will list all folders in a directory... example
\\server\users. so i would like all the folders names withing the users directory and list that to
notepad or excel. thanks in advance.
looking for a script htat will list all folders in a directory... example
\\server\users. so i would like all the folders names withing the users directory and list that to
notepad or excel. thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
First it creates a reference to the files system:
Dim objFSO: Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Using that , sets another object object to a report file for output info
Dim objOutput: Set objOutput = objFSO.CreateTextFile("C:\ Folders.tx t")
Establish a variable for the folder
fld="C:\ParentPath\"
run the sub, passing an object reference to that folder
EnumFolders (objFSO.GetFolder(fld))
'Once the sub is finished, close the file and destroy references..
objOutput.Close
Set objOutput=Nothing
Set objFSO = Nothing
wscript.quit
Sub EnumFolders(objFld)
'The next line writes the path of the folder to the output file
objOutput.WriteLine objFld.Path
The next section loops through all subfolders, restarting the sub for each found
For Each fld In objFld.SubFolders
EnumFolders (objFSO.GetFolder(fld))
Next
End Sub
Glad it worked for you. :^ )
Dim objFSO: Set objFSO = CreateObject("Scripting.Fi
Using that , sets another object object to a report file for output info
Dim objOutput: Set objOutput = objFSO.CreateTextFile("C:\
Establish a variable for the folder
fld="C:\ParentPath\"
run the sub, passing an object reference to that folder
EnumFolders (objFSO.GetFolder(fld))
'Once the sub is finished, close the file and destroy references..
objOutput.Close
Set objOutput=Nothing
Set objFSO = Nothing
wscript.quit
Sub EnumFolders(objFld)
'The next line writes the path of the folder to the output file
objOutput.WriteLine objFld.Path
The next section loops through all subfolders, restarting the sub for each found
For Each fld In objFld.SubFolders
EnumFolders (objFSO.GetFolder(fld))
Next
End Sub
Glad it worked for you. :^ )
ASKER
Thank you.
ASKER