Searching files for a string with VBscript
I need to make a script that searches all the text files in a folder for a specific string and if the file has that string, I need to save it do a different folder. I realize this may be a simple task for a real programmer, but I'm just a novice programmer. Please help. I've been able to figure out how to search a file for the string.
Dim objFSO, strLine, objReadFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile("C:\temp\Test.txt", 1, False)
Do Until objReadFile.AtEndOfStream
strLine = objReadFile.ReadLine
strLine = trim(strLine)
if instr(strLine, "123456") Then
'save this file to folder C:\temp\save\
set objFSO = nothing
I'm just not understanding how to do it for every file in the folder, and once it finds the string, how to save it to the other folder.
|All times are GMT +5.5. The time now is 20:45.|