Text file split script (VBS) _vbs

Source: Internet
Author: User
and Windows does not have an existing more useful segmentation tool, so I use VBS to do a text file segmentation tool, and you share. The script code is as follows:
Copy Code code as follows:

Option Explicit
' This script is only used to split text files, the script requires 3 parameters
' Argument list
' filename parameter 1 parameter 2
' Dream Studio www.mx111.com
' Example parameter 1 parameter 2 parameter meaning
' S 5 etc divided into 5 files
' E 1024 split file according to 1024 size
' F 1024 to the top 1024 bytes Save as a file
' L 1024 to save the last 1024 bytes as a file

Dim Tf,sf,fname,soufile,desfolder, Soption, Snum, FSO, FS, SFS

If WScript.Arguments.Count < 3 Then
WScript.Echo "parameter is wrong!"
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.