I needed a quick and dirty way to take two files with different content, but the same AMOUNT of content, and combine them into one file with File A's contents and File B's contents combined on the same corresponding line.
Here's what I came up with (I'm sure there are better ways, but hey, like I said, I'm not that great!)
Const ForReading1 = 1
Const ForReading2 = 1
DIM NEWID, OLDID, TS, TS2, NEWLINE, OLDLINE
set ACT=CreateObject("Wscript.shell")
set FSO=CreateObject("Scripting.FileSystemObject")
NEWID = "FileA.txt"
OLDID = "FileB.txt"
set TS = FSO.OpenTextFile(OLDID, ForReading1)
set TS2= FSO.OpenTextFile(NEWID, ForReading2)
set objMerged=FSO.CreateTextFile("mergedfiles.txt",8)
Do until TS.AtEndOfStream
OLDLINE = TS.READLINE
NEWLINE = TS2.READLINE
objMerged.WriteLine(NEWLINE & "," & OLDLINE)
Loop
TS.Close
TS2.Close
objMerged.close
Pages
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment