而Windows下沒有一個(gè)現(xiàn)存的比較好用的分割工具,所以我用VBS做了一個(gè)文本文件的分割工具,和各位網(wǎng)友共享。腳本代碼如下:
復(fù)制代碼 代碼如下:
Option Explicit
'這個(gè)腳本只用來分割文本文件,腳本需要3個(gè)參數(shù)
'參數(shù)列表
'文件名 參數(shù)1 參數(shù)2
'夢(mèng)想工作室 www.mx111.com
'示例 參數(shù)1 參數(shù)2 參數(shù)意義
' S 5 等分為5個(gè)文件
' E 1024 按照1024的大小分割文件
' F 1024 取最前面的1024字節(jié)存為一個(gè)文件
' L 1024 取最后面的1024字節(jié)存為一個(gè)文件
Dim tf,sf,fname,souFile,desFolder ,sOption , sNum , FSO , fs, sfs
If WScript.Arguments.Count 3 Then
WScript.Echo "參數(shù)有誤!"
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