VBScript - Concatenate Mulltiple Lines

I am looking for a way to string data together based on line counts with VBScript.  Every 8 lines should be concatenated into one line.  There is no unique delimiter in the data; just grab every 8 lines and concatenate into a single line.  Something like:

for i = 1 to 8 (where these would dynamically change, next loop through 9 to 17, etc).  

Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
Here's an example:

Set fso = CreateObject("Scripting.FileSystemObject")
Set input = fso.OpenTextFile("C:\path\to\file.txt", 1, True)  ' 1 = For Reading
Set output = fso.OpenTextFile("C:\path\to\result.txt", 2, True)  ' 2 = For Writing

counter = 1

While Not input.AtEndOfStream
    accumulator = accumulator & input.ReadLine()
    If counter Mod 8 = 0 Then
        accumulator = ""
    End If
    counter = counter + 1

If counter Mod 8 <> 0 Then
End If


Open in new window

I dumped the results to another file, but you can change this accordingly.
käµfm³d 👽Commented:
Where does the data come from? An existing string variable? Read from a file?
1500orionAuthor Commented:
This would come from a read of a text file.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.