因此暑假闲暇编写了这个简短精悍的脚本版的分割器。脚本版的最大的好处可以由使用者进行DIY。
具体情况就不多说了,关于txt编码的问题可以参考,iPod文本分割器
这里仅仅说明使用方法,将您需要分割的Txt文件直接拖放发到本脚本上就ok了。
以下是脚本代码,直接复制后保存为vbs文件就可以了!
Good Luck !
复制代码 代码如下:
'------------------------------------------------------------
' 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 : 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 "请把需要分割的Txt文件拖放到本脚本上!"
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 "无法找到文件" & 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
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 证声音乐图书馆《夏至 爵士境地》[320K/MP3][70.37MB]
- 孙露《同名专辑》限量1:1母盘直刻[低速原抓WAV+CUE]
- 【宝丽金唱片】群星《鼓舞飞扬》WAV+CUE
- 莫扎特弗雷德沃夏克肖斯塔科维奇《钢琴五重奏》(DG24-96)FLAC
- 证声音乐图书馆《夏至 爵士境地》[FLAC/分轨][360.16MB]
- 证声音乐图书馆《日落琴声 x 弦乐》[320K/MP3][71.2MB]
- 证声音乐图书馆《日落琴声 x 弦乐》[FLAC/分轨][342.58MB]
- 谢采妘2011《难忘的旋律(Non-StopChaCha)》马来西亚版[WAV+CUE]
- 林翠萍《听见林翠萍,记忆就会醒来》2CD[WAV+CUE]
- 木村好夫《天龍HIFI木吉他、木村好夫精选好歌》日本天龙版[WAV整轨]
- 证声音乐图书馆《日出琴声 x 民谣》[320K/MP3][53.76MB]
- 证声音乐图书馆《日出琴声 x 民谣》[FLAC/分轨][239.29MB]
- 证声音乐图书馆《绿意森林·吉他絮语》[320K/MP3][65.77MB]
- 证声音乐图书馆《绿意森林·吉他絮语》[FLAC/分轨][295.2MB]
- 证声音乐图书馆《流动与延展 彼拉提斯》[320K/MP3][56.88MB]