我在创建脚本方面没有受过教育,但我尝试根据我在互联网上找到的想法制作一个 vbscript。我的目标是转
[00:15:63]ki[00:16:09]e[00:16:36]ru
进入
[00:15.63]ki<00:16.09>e<00:16.36>ru
文件夹中每个文本文件的每行。
我目前正在尝试使用逐行循环来获取普通括号中的第一部分。但是,如果我在循环之前不写数据,我只会得到最后一行。但我不能同时阅读和写作。重复 tFile 读取会重置循环。我应该怎么办?这是它现在的当前代码(在第一个循环之后我缺少变量 tFile 的新集合):
'Strings for text values
strEXT = "txt"
Set objFolder = objFilesystem.GetFolder(SubFolder)
Set objFiles = objFolder.Files
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "(\d{2}):(\d{2}):(\d{2})"
strCount = 0
strCount2 = 0
'Parse each file and perform replacements
For Each objFile In objFiles
If Right(LCase(objFile.Name), 3) = strEXT Then
strCount = strCount + 1
Set tFile = objFile.OpenAsTextStream(ForReading, TriStateUseDefault)
do until tFile.atEndOfStream
strNextLine = tFile.ReadLine
If Len(strNextLine) > 0 Then
strLeft = Left(strNextLine, 10)
strRight = Mid(strNextLine, 11)
End If
strRight = Replace(strRight, "]", ">") ' ] to >
strRight = Replace(strRight, "[", "<") ' [ to <
strLeft = objRegEx.Replace _
(strLeft, "$1:$2.$3") ':xx: to :xx.
strRight = objRegEx.Replace _
(strRight, "$1:$2.$3") ':xx: to :xx.
tFile.Close
Set tFile = objFile.OpenAsTextStream(ForWriting, TriStateUseDefault)
tFile.Write strLeft
tFile.Write strRight
tFile.Close
loop
tFile.Close
end if
Next