大家好:
小弟对VBS一窍不通!
我今天在网上找了个VBS的文本分割脚本(附件1:VBS文件分割),但是我每次分割的话都要在脚本里修改源文件文件名,这样才能分割,挺麻烦的,请教高人能不能把这个VBS帮我改成(附件2:aabb.vbs)那样直接选择文件,然后来进行分割的,谢谢各位大侠了
附件1:
Set fs =CreateObject("scripting.filesystemobject")
Set gs =CreateObject("scripting.filesystemobject")
Set f=fs.opentextfile("url.txt",1,true) 'url.txt是要分割的txt文件
n=0
do while f.atendofstream<>true
n=n+1
data=""
Set g=gs.opentextfile(CStr(n)+".txt",2, true) '分割后的文件保存为:1.txt 2.txt 3.txt……
if f.atendofstream<>true then
for a=1 to 1000 '分割后,一个文件1000行
data=f.readline
g.writeline data
next
end if
loop
f.close
g.close
附件2:
set fso=createobject("scripting.filesystemobject")
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "vbs File|*.txt|All Files|*.*"
objDialog.InitialDir = ""
objDialog.ShowOpen
strLoadFile = objDialog.FileName
[ Last edited by xyz1234111 on 2011-1-17 at 19:51 ]
Set f = fso.OpenTextFile(strLoadFile,1,True) '要分割的txt文件
n = 0
Do While f.atendofstream <> True
n = n + 1
data = ""
Set g = fso.OpenTextFile(CStr(n) + ".txt",2, True) '分割后的文件保存为:1.txt 2.txt 3.txt……
If f.atendofstream <> True Then
For a = 1 To 1000 '分割后,一个文件1000行
data = f.ReadLine
g.writeline data
Next
End If