'------------------------------------------------------------
' 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 this script
' can also tranfrom the character coding.
' Author : Guoyafeng@
' Last Modified : 2008-8-31 11:05:13
'------------------------------------------------------------
Option Explicit
Sub OpenDir(Dir)
Dim WShell,CmdString
Set WShell = CreateObject("")
CmdString = " " & Dir
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 = 0 Then MsgBox "Please drag and drop the Txt file you want to split onto this script!"
Else
Dim fso
Set fso = CreateObject("")
If (((0))) Then
GetDragDropFile = (0)
Set fso = Nothing
Else
Set fso = Nothing
MsgBox "File Cannot Found" & (0)
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
= patrn
= True
= True
Set fso = CreateObject("")
BaseName = (GetDragDropFile)
OutFolderPath = ((GetDragDropFile),_
BaseName)
Set src = (GetDragDropFile, ForReading,False,_
TristateUseDefault)
If Not (OutFolderPath) Then
OutFolderPath
End If
Index = 1
While( <> True)
ToWrite = (MaxTextLength)
DestinationFile = (OutFolderPath,BaseName & _
FormatStrNum(Index) & ".txt")
Set dst=(DestinationFile,ForWriting,True,IIf(IsUnicode,TristateTrue,TristateUseDefault))
Dim SlimText
SlimText = (ToWrite,"")
SlimText
Set dst = Nothing
Index = Index + 1
Wend
Set src = Nothing
Set fso = Nothing
Set regEx = Nothing
OpenDir OutFolderPath