TXT text cutter supporting drag implemented by vbs

Time:2020-7-11

 SplitFile.vbs
‘/*=========================================================================   
‘* intro. TXT text cutter, the default is 8000 characters into a file. Drag is supported.    
‘ * FileName    SplitFile.vbs   
‘ * Author      yongfa365   
‘ * Version     v1.0   
‘ * MadeTime    2008-04-24 12:58:43   
‘ * LastModify  2008-04-24 12:58:43   
‘ *==========================================================================*/   

Set objArgs = WScript.Arguments   
If objArgs.Count = 0 Then  
Iiiii InputBox (“select text file to process”, “select text file to process”)
Else  

    For I001 = 0 To objArgs.Count – 1   
        IIIII objArgs(I001)   
    Next  
End If  

Function IIIII(Path)   
    TempStr = ReadFromFile(Path, “gb2312”)   
    Length = Len(TempStr)   
    iii = 0   
For II = 0 to length step 8000
        iii = iii + 1   
        WriteToFile Left(Path, Len(Path) -4) & “_” & Right(“00” & iii, 3) & “.txt” , Mid(TempStr, II + 1, 8000), “gb2312”  
    Next  
End Function  

  

Function ReadFromFile(FileUrl, CharSet)   
    Dim Str   
    Set stm = CreateObject(“Adodb.Stream”)   
    stm.Type = 2   
    stm.mode = 3   
    stm.charset = CharSet  
    stm.Open  
    stm.loadfromfile FileUrl   
    Str = stm.readtext   
    stm.Close  
    Set stm = Nothing  
    ReadFromFile = Str   
End Function  

‘store the file in the specified encoding

Function WriteToFile (FileUrl, Str, CharSet)   
    Set stm = CreateObject(“Adodb.Stream”)   
    stm.Type = 2   
    stm.mode = 3   
    stm.charset = CharSet  
    stm.Open  
    stm.WriteText Str   
    stm.SaveToFile FileUrl, 2   
    stm.flush  
    stm.Close  
    Set stm = Nothing  
End Function 

Recommended Today

Fluent learning diary (4) — interaction between fluent and native

Fluent and the principle of native interaction The communication between flutter and native adopts a dual channel event delivery mechanism, and transmits data through methodchannel. The communication principle is shown in the following figure (picture on the official website) It’s on the official websiteDocument addressIt is convenient for you to check. There are many examples […]