{"id":10133,"date":"2021-12-05T05:33:11","date_gmt":"2021-12-05T05:33:11","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=10133"},"modified":"2021-12-05T05:34:24","modified_gmt":"2021-12-05T05:34:24","slug":"solved-batch-file-replace-text-in-file","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/batch-file-replace-text-in-file\/30132.html","title":{"rendered":"Solved Batch File &#8211; Replace Text In File"},"content":{"rendered":"<p>Hey everyone,<\/p>\n<p>I need help replacing &#8220;Banana&#8221;=dword:00000001&#8221; with &#8220;Banana&#8221;=dword:00000000&#8243;<br \/>\ninside a .txt<\/p>\n<p>&nbsp;<\/p>\n<p>What I got so far is this<\/p>\n<p>@echo off<br \/>\nsetlocal enabledelayedexpansion<br \/>\nset INTEXTFILE=&#8221;C:\\Temp\\File.txt&#8221;<br \/>\nset OUTTEXTFILE=&#8221;C:\\Temp\\File_out.txt&#8221;<br \/>\nset SEARCHTEXT=&#8221;Banana&#8221;=dword:00000001<br \/>\nset REPLACETEXT=&#8221;Banana&#8221;=dword:00000000<\/p>\n<p>for \/f &#8220;tokens=1,* delims=\u00b6&#8221; %%A in ( &#8216;&#8221;type %INTEXTFILE%&#8221;&#8216;) do (<br \/>\nSET string=%%A<br \/>\nSET modified=!string:%SEARCHTEXT%=%REPLACETEXT%!<\/p>\n<p>echo !modified! &gt;&gt; %OUTTEXTFILE%<br \/>\n)<\/p>\n<p>The thing is that it gives the whole Output.<br \/>\nOnly the replacement part is wrong.<br \/>\nThats what it does in the line where it should replace the string<\/p>\n<p>dword:00000001=&#8221;Banana&#8221;=dword:00000000=dword:00000001<\/p>\n<p>Hope you can help me and many thanks already =)<\/p>\n<p align=\"right\"><span style=\"font-size: xx-small;\"><i>message edited by CharlyT<\/i><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":27},"question-category":[42],"question_tags":[],"class_list":["post-10133","question","type-question","status-publish","hentry","question-category-windows-7"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/10133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=10133"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=10133"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=10133"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=10133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}