title: Write Variable to file with For loop
body: <p>I have got a directory with about 20 (text)files. The content of these files is a MD5 hash sum. I would like to make a singel (text)file with the names of all de other files and the content of this files. The script I made works when I put the output to the screen, but when I write this to a file(test.txt) it only writes the first line? What am I doing wrong?</p>
  
  <p>e.g. </p>
  
  <p>file1  hjgd876kjkjkj7wde888dkjhkjhd78lkjlkjd98098</p>
  
  <p>file2  iueiuy8ss799sfdffs7gfgrg7kjnkj5564kljlj345</p>
  
  <p>file3  987fefdfges97sdfgg9766dgsdv097sdfdfg9866ds</p>
  
  <p>.....</p>
  
  <pre><code>@echo off
  
  SETLOCAL ENABLEEXTENSIONS
  
  
  
  rem %%L is the name of the files. %%K is the content of the files
  
  FOR /F "tokens=*" %%L IN ('dir /b *.sha') DO (
  
      for /F "tokens=*" %%K IN (%%L) DO echo %%L   %%K &gt;&gt; test.txt
  
  )
  </code></pre>