How to use vbs to calculate the number of times a word appears in a log file
This article introduces the knowledge of "how to use vbs to calculate the number of times a word appears in a log file". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The copy code is as follows:
Const ForReading = 1 Set objFSO = CreateObject ("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile ("c:\ scripts\ test.log", ForReading) strContents = objFile.ReadAll objFile.Close I = 0 arrLines = Split (strContents, ") For Each strLine in arrLines If InStr (strLine "Failure") Then I = I + 1 End If Next Wscript.Echo "Number of failures:" & I "how to use vbs to calculate the number of occurrences of a word in a log file" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!