vbscript to find a string value in a text file and then write an answer
Hey all
I have a vbscript that will read a folder directory and the files with each of the subfolders and then writes this to a txt file
sample of txt file
\\servername\packageinstalllogs$\AC-0012
Adobe_Acrobat_9_Pro.txt
\\servername\packageinstalllogs$\AC-0013
Adobe_Acrobat_9_Pro.txt
Adobe_Dreamweaver_CS5.txt
Adobe_Fireworks_CS5.txt
Adobe_Flash_CS5.txt
Adobe_Photoshop_CS5.txt
Mediator9.txt
\\servername\packageinstalllogs$\AC-0014
Adobe_Acrobat_9_Pro.txt
Adobe_Dreamweaver_CS5.txt
Adobe_Fireworks_CS5.txt
Adobe_Flash_CS5.txt
Adobe_Photoshop_CS5.txt
Mediator9.txt
What I need to add to the script is each txt file it finds I need it to open that file look for a script value if it finds it, it write as yes next to the file name if it does not find it, it writes a no.
The above sample would then change to this
\\servername\packageinstalllogs$\AC-0014
Adobe_Acrobat_9_Pro.txt, Yes
Adobe_Dreamweaver_CS5.txt, No
Adobe_Fireworks_CS5.txt, Yes
Adobe_Flash_CS5.txt, Yes
Adobe_Photoshop_CS5.txt, Yes
Mediator9.txt, Yes
The script I have at the moment is as follows
Dim FSO, LogFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set FSO = CreateObject ("Scripting.FileSystemObject")
objStartFolder = "\\servername\packageinstalllogs$"
Set LogFile = FSO.CreateTextFile("\\servername\packageinstalllog s$\packageinstallcheck.txt",True)
Set objFolder = objFSO.GetFolder(objStartFolder)
LogFile.writeLine objFolder.Path
Set colFiles = objFolder.Files
For Each objFile in colFiles
LogFile.writeLine objFile.Name
Next
LogFile.writeLine Echo
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
LogFile.writeLine Subfolder.Path
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
LogFile.writeLine objFile.Name
Next
LogFile.writeLine Echo
ShowSubFolders Subfolder
Next
End Sub
I have tried hitting the VBscript book off my head but it doesn’t seem to be working any help is appreciated
Thank you