Skip to content

Instantly share code, notes, and snippets.

@fastmover
Created January 25, 2017 21:20
Show Gist options
  • Select an option

  • Save fastmover/bd1be60a15d8f6dd441a211bdcfbcd98 to your computer and use it in GitHub Desktop.

Select an option

Save fastmover/bd1be60a15d8f6dd441a211bdcfbcd98 to your computer and use it in GitHub Desktop.
Converts escaped quotes: \" into Microsoft escaped quotes: "" in a text/CSVfile.
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = "\"""
File1 = WScript.Arguments.Item(0)
If wscript.arguments.count > 1 Then
File2 = wscript.arguments.item(1)
Else
File2 = File1
End If
Set objFile = objFSO.OpenTextFile(File1, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "\""", """""")
If objFSO.FileExists(File2) Then
Set objFile = objFSO.OpenTextFile(File2, ForWriting)
Else
Set objFile = objFSO.CreateTextFile(File2)
End If
objFile.WriteLine strNewText
objFile.Close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment