I can't test this right now, but this should do the trick.
jscript code:
var FSO = new ActiveXObject("Scripting.FileSystemObject"); // define globally
/* StringInFolder: return the next line of a file after a string match
- Folder: path to a folder to search
- String: text to search for in file
- Multi (optional): if true, an array for multiple matches will be returned */
function StringInFolder(Folder, String, Multi)
{
var Folder = FSO.GetFolder(Path);
var Return = [];
for (var Enum = new Enumerator(Folder.Files), !Enum.atEnd(), Enum.moveNext())
{
var File = Enum.item();
var Stream = File.OpenAsTextStream(1, -1);
if (!Stream.AtEndOfStream) // shouldn't be empty
{
var Text = Stream.ReadAll().split("\r\n");
var NextLine = false;
for (var Line in Text)
{
if (NextLine) // yes, we matched the previous line
{
if (Multi) // do we want an array of matches?
{
Return.push(Line);
NextLine = false;
}
else
{
return Line;
}
}
else if (Line.indexOf(String) !== -1) // found it!
{
NextLine = true; // flag to check the next line
}
}
}
Stream.Close();
}
}
var Result = StringInFolder("C:\\", "test", true); // example usage