title: Batch file to compare contents of a text file
body: <p>I have two text files which contain the below numbers</p>
  
  <pre><code>File1
  00000
  11111
  
  File2
  00000
  11111
  22222
  </code></pre>
  
  <p>I need a code which compares the contents of file2 to that of file1 and the numbers which are not matched , in this case '22222' be the only content in file2.</p>
  
  <p>In short i want to erase the content of file2 and put the non matched content in file2. Below is the code i have tried but it just erases the entire thing in the file2.</p>
  
  <pre><code>setlocal enabledelayedexpansion
  
  for /f "tokens=1" %%a in (file1) do (type file2 | findstr /v %%a &gt; file2)
  
  pause
  </code></pre>
  
  <p>Bottom line i need to achieve the below results</p>
  
  <pre><code>File1
  00000
  11111
  
  File2
  22222
  </code></pre>
  
  <p>Help please ! </p>