title: Find and replace string in multiple files within a folder using windows Batch script
body: <p>I am trying to write a batch file to find and replace a string in multiple files within a folder. But I am getting this error:</p>
  
  <blockquote>
    <p>Cannot perform a cyclic copy</p>
  </blockquote>
  
  <p>Any idea why that happens?</p>
  
  <pre><code>@echo off
  SETLOCAL
  for %%* in (.) do set foldername=%%~n*
  SET stringtofindreplace=XXXX
  for %%f in (*.fmw) do (
      echo Processing %%f...
      fOR /F "delims=" %%l IN (%%f) DO (
           SET "line=%%l"
           SETLOCAL ENABLEDELAYEDEXPANSION 
           set "x=!line:%stringtofindreplace%=%foldername%!" 
           echo(!x!
           ENDLOCAL)
      )&gt;%%~nf.new
  )
  GOTO:EOF
  </code></pre>