I have no education in creating scripts but I tried making a vbscript based on ideas that I found on the internet. My objective is to turn
[00:15:63]ki[00:16:09]e[00:16:36]ru
into
[00:15.63]ki<00:16.09>e<00:16.36>ru
per line for each text file in a folder.
I'm currently trying to use a line by line loop to get the first part in normal brackets. However, if I don't write the data before it loops I only get the last line. But I can't read and write at the same time. Repeating the tFile to read resets the loop. What should I do? This is the current code for it right now (where I'm lacking a new set for variable tFile after the first loop):
'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