I have a bunch of VBScripts that I created using help from this forum and other forums. These scripts are for fixing Windows problems, installing software and setting configuration settings. Each script is in a separate folder. Some of the script folders contain a file called ReadMe.txt that contains info about the script and what it does. I am trying to document all my fixes so I can share them with coworkers, friends and anyone who needs help. I struggle with the "recursive" feature in VBScript. I found the Scripting Guy's article on recursive searching and found another article from another website that works really well for listing all folders and subfolders to a CSV file. I'm having trouble adapting the script. After it exports the folder list to the CSV, I need it to go back through the list and for every folder that contains the ReadMe.txt, export it's contents to the row for the specific folder that contains the file.
I've tried several modifications of this script but all my attempts cause the script to Not export the file list. I cannot get past this problem. Until I do that I cannot even focus on the exporting the contents of the ReadMe.txt file to the CSV file.
Here is the code I have
Dim objFSODim ObjOutFile
'Creating File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Create an output file
Set ObjOutFile = objFSO.CreateTextFile("OutputFiles.csv")
'Writing CSV headers
ObjOutFile.WriteLine("Type,File Name,File Path")
'Call the GetFile function to get all files
GetFiles("H:\0-Fixes")
'Close the output file
ObjOutFile.Close
WScript.Echo("Completed")
Function GetFiles(FolderName)
On Error Resume Next
Dim ObjFolder
Dim ObjSubFolders
Dim ObjSubFolder
Dim ObjFiles
Dim ObjFile
Set ObjFolder = objFSO.GetFolder(FolderName)
Set ObjFiles = ObjFolder.Files
'Write all files to output files
For Each ObjFile In ObjFiles
ObjOutFile.WriteLine("File," & ObjFile.Name & "," & ObjFile.Path)
Next
'Getting all subfolders
Set ObjSubFolders = ObjFolder.SubFolders
For Each ObjFolder In ObjSubFolders
'Writing SubFolder Name and Path
ObjOutFile.WriteLine("Folder," & ObjFolder.Name & "," & ObjFolder.Path)
'Getting all Files from subfolder
GetFiles(ObjFolder.Path)
Next
End Function
Helpful nice guy