In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how VBS implements text file splitting scripts. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
And Windows does not have an existing better segmentation tool, so I used VBS to do a text file segmentation tool, and you share. The script code is as follows:
The code is as follows:
Option Explicit
'This script is only used to split text files, the script requires 3 parameters
'Parameter list
'File name Parameter 1 Parameter 2
'Example Parameter 1 Parameter 2 Parameter Meaning
' S 5 is divided into 5 files
' E 1024 Split file by size of 1024
' F 1024 Take the first 1024 bytes and save them as a file
' L 1024 Take the last 1024 bytes and save them as a file
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
Thank you for reading! About "VBS how to achieve text file segmentation script" This article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.