I have this script for combining text files which works fine, but I have hit a big road block. I have a directory that contains approx 500 text files that I need to combine with a condition. I have many "pairs" of files that are job files where the name is like "JOB-A-TOP" & "JOB-A-BTM". I need to combine all of the pairs with the "-TOP" & "-BTM". Can someone assist me to get me started on how to accomplish this?
Code:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile("Merged.txt")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\Combine_These'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In FileList
Set objTextFile = objFSO.OpenTextFile(objFile.Name, ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
objOutputFile.WriteLine objFile.Name & ", " & strText
Next
objOutputFile.Close