{"id":4903,"date":"2014-03-30T16:41:11","date_gmt":"2014-03-30T16:41:11","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/windows-batch-file-replace-a-string-in-an-xml-file-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:41:11","modified_gmt":"2014-03-30T16:41:11","slug":"windows-batch-file-replace-a-string-in-an-xml-file-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/windows-batch-file-replace-a-string-in-an-xml-file-collection-of-common-programming-errors\/","title":{"rendered":"Windows batch file &#8211; replace a string in an XML file-Collection of common programming errors"},"content":{"rendered":"<p>Batch will have trouble with , ^ and &amp; characters. This will work, but a JScript\/VBScript script (like is referenced in one of the comments) is a much better solution.<\/p>\n<p>Change &#8220;ORIGINAL&#8221; to the text being searched for, and &#8220;REPLACE&#8221; to the new text. I recommend for Windows scripting to learn JScript.<\/p>\n<pre><code>@echo off\nfor \/f \"tokens=* delims=\" %%f in ('type sometext.txt') do CALL :DOREPLACE \"%%f\"\n\nGOTO :EOF\n:DOREPLACE\nSET INPUT=%*\nSET OUTPUT=%INPUT:ORIGINAL=REPLACE%\n\nfor \/f \"tokens=* delims=\" %%g in ('ECHO %OUTPUT%') do ECHO %%~g&gt;&gt;out.txt\n\nEXIT \/b\n\n:EOF\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Batch will have trouble with , ^ and &amp; characters. This will work, but a JScript\/VBScript script (like is referenced in one of the comments) is a much better solution. Change &#8220;ORIGINAL&#8221; to the text being searched for, and &#8220;REPLACE&#8221; to the new text. I recommend for Windows scripting to learn JScript. @echo off for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4903","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4903"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4903\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}