title: Change a string within a line from a text file using batch
body: <p>I have text file (saved as *.pm but I assume it does not make any difference as it can be open as a text file). The content of the file looks something like:</p>
  
  <pre><code>Header
  
  $VAR1 = {
            'Keywords' =&gt; {
                                 'X' =&gt; '80',
                                 'Target_Path' =&gt; 'Example_PAth',
                                 'Y' =&gt; 'File_Path',
                                 'X' =&gt; '80',
                                 'Y' =&gt; 'File_Path',
                                 'X' =&gt; '80',
                                 'Y' =&gt; 'File_Path',
                 sdefkjnhksdf  koijsef ökiljsdf
                 sdefkjnhksdf  koijsef ökiljsdf
                 sdefkjnhksdf  koijsef ökiljsdf
  </code></pre>
  
  <p>I want to change <strong>Example_PAth</strong> to <strong>Example_PAth_New</strong> using a *.bat file.</p>
  
  <p>For this I have the following code:</p>
  
  <pre><code>@echo off
  setlocal disableDelayedExpansion
  
  :Variables
  set InputFile=OldFileName.pm
  set OutputFile=NewFileName.pm
  set "_strFind=Example_PAth"
  set "_strInsert=Example_PAth_New"
  
  :Replace
  &gt;"%OutputFile%" (
    for /f "usebackq delims=" %%A in ("%InputFile%") do (
      if "%%A" equ "%_strFind%" (echo %_strInsert%) else (echo %%A)
    )
  
  )
  </code></pre>
  
  <h2><strong>Problem:</strong> The resulting file is identical to the original one. I assume I am not reading the string properly? Or does anyone have an idea how to fix the code?</h2>
  
  <p><strong><em>Update:</em></strong>
  I now modified the searched and substituted strings to include the whole line as mentioned by @Squashman. It works perfectly if the searched strings does not include the <strong>></strong> character. If I keep the <strong>></strong>, the line is detected properly but it will be replaced by a blank line. Any workaround? PS: I can't omit the > character. </p>