View Single Post
 
Old 08-14-2014, 03:51 AM
josianne josianne is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Aug 2014
Posts: 2
josianne is on a distinguished road
Default list folders and files using .vbs file

Hello guys!
I'm very new on programming but I'm enjoying it so far .
I need help to make a vbs file that returns a list of files and subfolders of main folder
SO FAR I HAVE THIS (but it doesnt separates the fields in different columns)

Code:
Dim fso
Dim ObjOutFile 

Set fso = CreateObject("Scripting.FileSystemObject") 

Set ObjOutFile = fso.CreateTextFile("OutputFiles.csv")

ObjOutFile.WriteLine("Type,File Name,File Path")

GetFiles("C:\Intel") 

ObjOutFile.Close 
WScript.Echo("Completed")
Function GetFiles(FolderName) 
On Error Resume Next 
Dim ObjFolder
Dim ObjSubFolders 
Dim ObjSubFolder 
Dim ObjFiles 
Dim ObjFile 
Set ObjFolder = fso.GetFolder(FolderName)
Set ObjFiles = ObjFolder.Files 

For Each ObjFile In ObjFiles 
ObjOutFile.WriteLine("File," & ObjFile.Name & "," & ObjFile.Path) 
Next 

Set ObjSubFolders = ObjFolder.SubFolders 
For Each ObjFolder In ObjSubFolders 

ObjOutFile.WriteLine("Folder," & ObjFolder.Name & "," & ObjFolder.Path) 

GetFiles(ObjFolder.Path) 
Next 
End Function

Thanks in advance all you guys!
You'll have a very thankfull girl posting here!
Reply With Quote