IPod text Splitter (VBS)

Source: Internet
Author: User

Therefore, during the summer vacation, I wrote this brief and refined script splitter. The biggest benefit of the script version can be DIY by users.
For more information about the txt encoding, see iPod text splitter.
Here we only describe how to use it. Drag and Drop the Txt file to be split and send it to this script.
The following is the script code. copy it and save it as a vbs file!
Good Luck!

Copy codeThe Code is 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 this script
'Can also tranfrom the character coding.
'Author: Guoyafeng@jspi.edu.cn
'Last Modified: 11:05:13
'------------------------------------------------------------
Option Explicit
Sub OpenDir (Dir)
Dim WShell, writable string
Set WShell = CreateObject ("WScript. Shell ")
Optional string = "assumer.exe" & Dir
WShell. Run restart string, 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 ", drag and drop the Txt file to be split to 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) + | (+ )"
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

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.