JuniperGreen
Member
I have a file which holds lines of text. One line of text indicates a file's location the following line holds a description of the file. I want to be able to search the file using "the directory" as the keyword and where a match is found extract the following line also so I have both the file location and description. For example by searching for one of the directories such as "/s/" I would be able to identify all the files which are in it along with their descriptions. The script below lets me identify all the directory matches but I am stumped as to how I can extract the line following the match so that I have the description as well. There is no way I can search for the descriptions as they are unique.
Any help on how I might achieve this would be appreciated
Thank you
Any help on how I might achieve this would be appreciated
Thank you
Code:
Const ForReading = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "./s/"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("F:\H&S_Safety_Matters\H&S_Items.txt", ForReading)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
For Each strMatch in colMatches
Wscript.Echo strSearchString
Next
End If
Loop
objFile.Close