了解- Set fso=CreateObject("scripting.filesystemobject")
- If fso.fileexists("e:\a.txt") Then
- Set ofile=fso.OpenTextFile("e:\a.txt",1)
- Else
- wscript.echo "the file is not exists"
- WScript.Quit(1)
- End If
- str=ofile.readall
- arr=Split(str,vbCrLf)
- nfile=UBound(arr)/10+1 '此处有点问题,最好用MOD来判断一下,要不如果是10的倍数的话,可能会多创建一个文件。不过在此就不改了
- nnum=0
- For i=1 To nfile
- If Not fso.FileExists(i&".txt") Then
- Set newfile=fso.OpenTextFile(i&".txt",2,True)
- Else
- WScript.Echo i&".txt file is exists"
- WScript.Quit(2)
- End If
- number=0
- For n=nnum To uBound(arr)
- number=number+1
- If (number<>10 and ofile.AtEndOfStream) Then
- newfile.WriteLine arr(n)
- Else
- Exit for
- End If
- Next
- nnum=i*10
- newfile.Close
- Set newfile=nothing
- Next
- ofile.Close
- Set fso=Nothing
复制代码
|