1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject" )
Set objFile = objFSO.OpenTextFile("C:\Users\Utilisateur\Desktop\fichier1.txt", ForReading)
Do While Not objFile.AtEndOfStream
strText = objFile.ReadLine
If InStr(1, LCase(strText), "success", vbTextCompare) <> 0 And _
InStr(1, LCase(strText), "ok backup", vbTextCompare) = 0 Then
strNewText = strNewText & Replace(strText, "backup", "OK backup") & vbNewLine
ElseIf InStr(1, LCase(strText), "failed", vbTextCompare) <> 0 And _
InStr(1, LCase(strText), "ko backup", vbTextCompare) = 0 Then
strNewText = strNewText & Replace(strText, "backup", "KO backup") & vbNewLine
Else
strNewText= strNewText & strText & vbNewLine
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("C:\Users\Utilisateur\Desktop\fichier1.txt", ForWriting)
objFile.Write strNewText
objFile.Close |
Partager