开发者

Output each line of text (+ the first line) to its own .txt file VBS-Script

开发者 https://www.devze.com 2023-01-19 08:41 出处:网络
I need a VBS script to output the first line of text along with another line of text for file data.txt.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号