title: find and replace in txt file using .cmd file
body: <p>i have created a .cmd file which takes file name as argument then it asks for string to find and then string to replace.</p>
  
  <p>desired out put </p>
  
  <p>findthis should be replaced from given file with replacewith but it is not working</p>
  
  <p>following is code which i have tried..</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  
  if not exist "%1" (echo this file does not exist...)&amp;goto :eof
  
  set /p findthis=find this text string:
  set /p replacewith=and replace it with this:
  
  
  for /f "tokens=*" %%a in (%1) do (
  
     set write=%%a
     if %%a==%findthis% set write=%replacewith%
  
     echo !write! 
     echo !write! &gt;&gt;%~n1.replaced%~x1
  )
  </code></pre>
  
  <p>thanks </p>