I'm totally a beginner here, this is the most complicated script I've attempted beyond simple batch files. I'm going to post this on some vbs forums but I'm hoping someone here might be able to help too. I'm trying to read multiple text files grabbed by extension and write out a specific record from each one to a separate text file. I keep running into issues with line 23; it says there is no object specified and I can't see where I need to add the additional object. Any vbs gurus in the house?
'Grab any file with a .DAT extension
'Search file for record 100
'Output record 100 to another file
set fso = CreateObject("Scripting.FileSystemObject")
dim fso
dim infolder
dim outfolder
dim infile
dim outfile
set infolder = fso.GetFolder("c:\Scripts\test files")
Set outfolder = fso.GetFolder("c:\Scripts\ready files")
set outfile = fso.OpenTextFile("c:\Scripts\ready files\totals.txt")
for each file in fso.GetFolder(infolder).Files
if (fso.GetExtensionName(file.name)) = "DAT" then
basename = fso.GetBaseName(file.name)
infile = fso.BuildPath(infolder, basename & ".DAT")
'readin = fso.OpenTextFile(infile, 1, True)
set stream = fso.OpenTextFile(infile, 1)
Do Until infile.AtEndOfStream
'line = infile.ReadLine
'If Mid(line, 1, 3) = "100" Then _
'outfile.WriteLine line
loop
end if
Next
stream.close
Wscript.quit