文本文件分割脚本(VBS)
导读:收集整理的这篇文章主要介绍了文本文件分割脚本(VBS ,觉得挺不错的,现在分享给大家,也给大家做个参考。 而Windows下没有一个现存的比较好用的分割工具,所以我用vbS做了一个文本文...
收集整理的这篇文章主要介绍了文本文件分割脚本(VBS),觉得挺不错的,现在分享给大家,也给大家做个参考。 而Windows下没有一个现存的比较好用的分割工具,所以我用vbS做了一个文本文件的分割工具,和各位网友共享。脚本代码如下: 复制代码 代码如下:
Option ExplicIT
'这个脚本只用来分割文本文件,脚本需要3个参数
'参数列表
'文件名 参数1 参数2
'梦想工作室 www.mx111.COM
'示例 参数1 参数2 参数意义
' S 5 等分为5个文件
' E 1024 按照1024的大小分割文件
' F 1024 取最前面的1024字节存为一个文件
' L 1024 取最后面的1024字节存为一个文件
Dim tf,sf,fname,souFile,desFolder ,sOption , sNum , FSO , fs, sfs
If WScript.arguments.Count 3 Then
WScript.Echo "参数有误!"
WScript.Quit
Else
souFile = WScript.arguments(0)
sOption = WScript.Arguments(1)
sNum = WScript.Arguments(2)
End If
Set FSO = CreateObject("Scripting.FileSystemObject")
Set tf=FSO.GetFile(souFile)
fs = tf.Size
Set tf = fso.OPEnTextFile(souFile, 1)
Dim x
Select Case sOption
Case "S"
sfs = Int ( fs / sNum )
for x=1 to sNum-1
SaveSubFile "file_" & x & ".txt", 0 ,sfs
Next
SaveSubFile "file_" & sNum & ".txt", 0 , fs - sfs * (sNum-1)
Case "E"
sfs = sNum
sNum = Int ( fs / sfs) + 1
for x=1 to sNum-1
SaveSubFile "file_" & x & ".txt", 0 ,sfs
Next
SaveSubFile "file_" & sNum & ".txt", 0 , fs - sfs * (sNum-1)
Case "F"
SaveSubFile "file_" & 0 & ".txt", 0 , sNum
Case "L"
SaveSubFile "file_" & 0 & ".txt", fs - sNum , sNum
End Select
tf.Close
Sub SaveSubFile(s,b,l)
Dim sfile,content
WScript.Echo s & ":" & b & ":" & l
Set sfile = fso.CreateTextFile(s, TRUE)
If b> 0 Then
tf.Skip(b)
End If
content = tf.Read(l)
sfile.Write(content)
sfile.Close
End Sub
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 文本文件分割脚本(VBS)
本文地址: https://pptw.com/jishu/609847.html
