Output each line of text (+ the first line) to its own .txt file VBS-Script
I need a VBS script to output the first line of text along with another line of text for file data.txt.
example of my开发者_如何学C text.txt file
line1 + line2 to 1.txt line1 + line3 to 2.txt line1 + line4 to 3.txt
Thanks in advance, Best regards, joe
Long time since i used VBS
Set fso = CreateObject("Scripting.FileSystemObject")
set src = fso.OpenTextFile("test.txt",1)
lines = split(src.readall,vbcrlf)
for i = 1 to ubound(lines)
set dst = fso.CreateTextFile( i & ".txt", true)
dst.writeline lines(0)
dst.writeline lines(i)
dst.close
next
You can write to files using the FileSystemObject. This page shows some sample code for opening and writing to a file: Working with Files
精彩评论