title: Set variables for each line of a txt file in a batch code
body: <p>Is there a way to set each line of a txt document as a different variable in a batch file? I have got a txt file with all drives found on the computer. How can I set each line (for each drive) as a different variable, if this is possible at all?</p>
  
  <p>I have a file which writes all avalible drives in a text file. I want to read this file out and set a different variable for each line of text. For example:</p>
  
  <pre><code>    DeviceID  
      C:        
      D:        
      E:        
  </code></pre>
  
  <p>Now "DeviceID" would be the first variable. "C:" "D:" and "E:" are all getting individual variables. I hope you get what I mean.</p>
  
  <p>Thanks in advance!</p>
  
  <p>Okay so I've tried this:</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  set i=0
  for /f "tokens=2 delims=:=" %%a in ('wmic logicaldisk get name /value ') do (
    set /a i+=1
    set drive[!i!]=%%a
  )
  set drive
  pause
  copy %0 %drive[1]%:\%random%.bat
  pause
  </code></pre>
  
  <p>And it works pretty well. But I want to copy the currently executed file to all drives found without typing:</p>
  
  <pre><code>copy %0 %drive[1]%:\currentlyexecutedfile.bat
  copy %0 %drive[2]%:\currentlyexecutedfile.bat
  copy %0 %drive[3]%:\currentlyexecutedfile.bat
  copy %0 %drive[4]%:\currentlyexecutedfile.bat
  </code></pre>
  
  <p>Is there a way to do this, without knowing how many drives there are and without causing errors?</p>