手机
当前位置:查字典教程网 >脚本专栏 >vbs >文本文件分割脚本(VBS)
文本文件分割脚本(VBS)
摘要:而Windows下没有一个现存的比较好用的分割工具,所以我用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)】相关文章:

VBS 批量读取文件夹内所有的文本到Excel的脚本

用vbs对文本文件的内容进行排序

用VBScript写合并文本文件的脚本

VBS如何察看或获得剪切板内容的脚本

vbs复制文件的脚本

vbs通过WMI修改文件文件夹的NTFS权限

用vbscript实现从文本文件中删除所有重复行的代码

利用vbscript脚本修改文件内容,此适用于自动化的操作中

用来分割文本的vbs脚本

VBS相册生成脚本[

精品推荐
分类导航