title: A Batch file to read a file and replace a string with a new one
body: <p>I want to create a batch file to read every line of a file in a loop and replace a string with another one. Following is my code snippet:</p>
  
  <pre><code>for /F "tokens=*" %%i in (myfile) do (
    set str=%%i
    set str=%str: %oldstring% = %newstring%%
  echo %str% &gt;&gt; newfile
  )
  </code></pre>
  
  <p>This results in a newfile with 'Echo is off' as many lines as there are in myfile. Seems like str variable holds no value at all when assigned to %%i. Can someone help me?</p>