用来分割文本的vbs脚本
程序员文章站
2022-08-27 16:53:25
复制代码 代码如下: on error resume next 'code by netpatch set arg=wscript.arguments if arg.cou...
复制代码 代码如下:
on error resume next
'code by netpatch
set arg=wscript.arguments
if arg.count=0 then wscript.quit
set fso = createobject("scripting.filesystemobject")
set conn = createobject("adodb.connection")
set rs = createobject("adodb.recordset")
path=left(arg(0),instrrev(arg(0),"\"))
fname=replace(arg(0),path,"")
i=0
conn.open "provider=microsoft.jet.oledb.4.0;data source="&path&";extended properties=""text;hdr=no;fmt=delimited"""
'rs.open "select count(*) from " & fname,_
'conn, 3, 3, &h0001
'allline=rs(0)
rs.open "select * from " & fname,_
conn, 3, 3, &h0001
'msgbox rs(0).name
do until rs.eof 'n/p
do until n=5000 '要分割的行数
set mytables = fso.createtextfile(arg(0)&i&".txt",true)
mytables.writeline rs.fields.item(0).value
rs.movenext
n=n+1
loop
mytables.close
set mytables = nothing
n=0
i=i+1
loop
rs.close
conn.close
set fso = nothing
set rs = nothing
set conn = nothing
wscript.echo "整理完毕!"
下一篇: VBS教程:方法-Exists 方法