I have been using Notepad++ to make adjustments to a TXT file. I was wondering if its possible to automate this using VBScript?
\r\n
with " " (a blank space).I0
with \nI0
.X0
with \nI0
.The below example is suitable for Unicode and ASCII text files:
sPath = "C:\Users\DELL\Desktop\tmp\test.txt"
sContent = ReadTextFile(sPath, 0) ' lFormat -2 - System default, -1 - Unicode, 0 - ASCII
sContent = Replace(sContent, vbCrLf, " ")
sContent = Replace(sContent, "I0", vbLf & "I0")
sContent = Replace(sContent, "X0", vbLf & "I0")
WriteTextFile sContent, sPath, 0
Function ReadTextFile(sPath, lFormat)
With CreateObject("Scripting.FileSystemObject").OpenTextFile(sPath, 1, False, lFormat)
ReadTextFile = ""
If Not .AtEndOfStream Then ReadTextFile = .ReadAll
.Close
End With
End Function
Sub WriteTextFile(sContent, sPath, lFormat)
With CreateObject("Scripting.FileSystemObject").OpenTextFile(sPath, 2, True, lFormat)
.Write sContent
.Close
End With
End Sub
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments