欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用来分割文本的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 "整理完毕!"