title: Replace a fixed value with a variable in a text file with batch
body: <p>I want to replace <code>OLD</code> with <code>%NEW%</code> in <code>test.txt</code> by using a batch file:</p>
  
  <pre><code>@echo off 
  set /p NEW=""
  set InputFile=test.txt
  find OLD
  replace %NEW%
  </code></pre>
  
  <p>my test.txt contains various characters like <code>~</code> <code>:</code> <code>;</code> <code>_</code> <code>.</code>which I attribute to various solutions clapping out.</p>
  
  <p>I have attempted to use <a href="http://www.dostips.com/DtCodeBatchFiles.php#Batch.FindAndReplace" rel="nofollow">BatchSubstitude.bat</a> to achieve this but it does not "find" <code>OLD</code> and does not replace any text.</p>
  
  <p>I have also attempted to use <a href="http://fart-it.sourceforge.net/" rel="nofollow">fart.exe</a> but I receieve an error when trying to perform this:</p>
  
  <pre><code>find_string="OLD"
  replace_string="test"
  actual find_length=3
  actual replace_length=4
  processing \filepath\,test.txt
  skipping binary file: \filepath\test.txt
  </code></pre>
  
  <p>The documentation for this is sparse and nothing I could google furiously would provide a solution.</p>
  
  <p>The reason I am using batch for the moment is that I perform various windows CE  actions such as cecopy, pdel and rapistart for windows CE deployment over activesync and batch seems to be the easiest way to to get the result that I am after - and I'm a total noob at batch.</p>
  
  <p>Does anyone know how this can be achieved with batch and perhaps explain how the various functions work to achieve this?</p>
  
  <p>Cheers!</p>