So in the summer vacation to write this short and vigorous script version of the separator. The biggest benefit of the scripting version can be DIY by users.
The specific situation is not much said, on the TXT coding problem can refer to the ipod text separator
Here only describes the use of methods, you need to split the TXT file directly drag and drop to the script on the OK.
The following is the script code, directly copied after saving as a VBS file on it!
Good Luck!
Copy Code code as follows:
'------------------------------------------------------------
' Description:text Division for IPod Text Reading.
' Because of IPod can not display text length
' More than 4KB in each file, we have to split
' The bigger one.
' and IPod intrenal use Unicode-so ' script
' Can also tranfrom the character coding.
' Author:guoyafeng@jspi.edu.cn
' Last modified:2008-8-31 11:05:13
'------------------------------------------------------------
Option Explicit
Sub Opendir (Dir)
Dim wshell,cmdstring
Set Wshell = CreateObject ("Wscript.Shell")
cmdstring = "Explorer.exe" & Dir
Wshell.run Cmdstring,1,true
End Sub
Function Formatstrnum (Inum)
Const Mode = "0000"
Dim Snum
Snum = CStr (inum)
Formatstrnum = Left (Mode,len (Mode)-len (snum)) & Snum
End Function
Function IIf (test,a,b)
If test = True Then iif = a Else iif = b
End Function
Function Getdragdropfile
If WScript.Arguments.Count = 0 Then MsgBox "Please drag and drop the TXT file you want to split into this script!" "
Wscript.Quit
Else
Dim FSO
Set fso = CreateObject ("Scripting.FileSystemObject")
If (FSO). FileExists (wscript.arguments (0)) Then
Getdragdropfile = wscript.arguments (0)
Set FSO = Nothing
Else
Set FSO = Nothing
MsgBox "File not Found" & WScript.Arguments (0)
Wscript.Quit
End If
End If
End Function
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const TristateTrue =-1
Const tristateusedefault=-2
Const tristatefalse=0
Dim Towrite
Dim Index
Dim FSO
Dim SRC
Dim DST
Dim Textsize
Dim Maxtextlength
Dim sourcefile
Dim Destinationfile
Dim BaseName
Dim Outfolderpath
Dim Isunicode
Dim regex,patrn
'***************************************************************
' Splited text size.
Textsize = 4 ' KB
Isunicode = True
'*****************************************************************
Maxtextlength = 1024 * TEXTSIZE/2-1
PATRN = "(\r\n\r\n) +| (+) "
Set regEx = New RegExp
Regex.pattern = patrn
Regex.ignorecase = True
Regex.global = True
Set fso = CreateObject ("Scripting.FileSystemObject")
BaseName = fso. Getbasename (Getdragdropfile)
Outfolderpath = fso. BuildPath (FSO. Getparentfoldername (Getdragdropfile), _
BaseName)
Set src = fso. OpenTextFile (Getdragdropfile, forreading,false,_
Tristateusedefault)
If not FSO. FolderExists (Outfolderpath) Then
Fso. CreateFolder Outfolderpath
End If
Index = 1
while (SRC. AtEndOfStream <> True)
Towrite = src. Read (Maxtextlength)
Destinationfile = fso. BuildPath (Outfolderpath,basename & _
Formatstrnum (Index) & ". txt")
Set Dst=fso. OpenTextFile (Destinationfile,forwriting,true,iif (Isunicode,tristatetrue,tristateusedefault))
Dim Slimtext
Slimtext = Regex.Replace (Towrite, "")
Dst. Write Slimtext
Dst. Close
Set DST = Nothing
index = index + 1
Wend
Src. Close
Set src = Nothing
Set FSO = Nothing
Set regEx = Nothing
Opendir Outfolderpath