华域联盟 vbs 文本文件分割脚本(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

本文由 华域联盟 原创撰写:华域联盟 » 文本文件分割脚本(VBS)

转载请保留出处和原文链接:https://www.cnhackhy.com/15941.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部