Hello,
I am having a little trouble. Here is what I am trying to do.
Search all text files in a folder for a string
If that string is found than merge those text files that were found.
Any help to point me in the right direction would be great.
I am having no problem with the search for string part
The above code searches for the needed string and copies the file to a new name. But only for one file. I have more than one file with the search string in it and need to merge all files with the search string in them.
Thank you
I am having a little trouble. Here is what I am trying to do.
Search all text files in a folder for a string
If that string is found than merge those text files that were found.
Any help to point me in the right direction would be great.
I am having no problem with the search for string part
Code:
Set colFiles = objFolder.Files
For Each objFile in colFiles
'Wscript.Echo objFile.Name
strFile = "\\path to folder\" & objFile.Name
set objFile = objFSO.getFile(strFile)
if objFile.size > 0 then
If InStr(oFSO.OpenTextFile(strFile).ReadAll, strSearchFor) > 0 Then
filesys.CopyFile "\\path to folder\" & objFile.Name, "\\path to folder\" & "Name_"& strDate &".txt"
Else
WScript.Sleep (100)
END If
END If
NextThank you