Created
January 25, 2017 21:20
-
-
Save fastmover/bd1be60a15d8f6dd441a211bdcfbcd98 to your computer and use it in GitHub Desktop.
Converts escaped quotes: \" into Microsoft escaped quotes: "" in a text/CSVfile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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