can someone help me to update below code to split main data file by multiple wordings.

Example: Search line by line If the word "DEF" found then save them in the DEF data file until all found, and the same search for additional 6 more words to search line by line until the desired strings are found, then copy the entire line into desired split files.

'when this scripts completed, then I expect to have 7 individual split files !

' Variables declarations.
Option Explicit
const cRead=1, cWrite=2, cAppend=8
dim FSO
set FSO=CreateObject("Scripting.FileSystemObject")
dim fileInput, fileOutput, stringtosearch,strArray

' Open the current input file
Set fileInput=FSO.OpenTextFile(Watch.GetJobFilename, cRead)

' Loop through the lines. Do a search and extract desired line of data and save them into another file.

do while not (fileInput.AtEndOfStream)
stringtosearch = fileInput.ReadLine()

if ((mid(stringtosearch, 1, 10) = "ABC")) then
objOutputFile.WriteLine(sLine)
end if

if ((mid(stringtosearch, 1, 10) = "DEF")) then
objOutputFile.WriteLine((sLine)
end if
loop

objInputFile.Close
objOutputFile.Close
objFSO.DeleteFile Watch.GetJobFilename, true



Edited by Sami786 (06/14/21 01:58 PM)
_________________________
Peace