title: Windows Batch file to echo a specific line number
body: <p>So for the second part of my current dilemma, I have a list of folders in <code>c:\file_list.txt</code>.  I need to be able to extract them (well, echo them with some mods) based on the line number because this batch script is being called by an iterative macro process.  I'm passing the line number as a parameter.</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  set /a counter=0
  set /a %%a = ""
  for /f "usebackq delims=" %%a in (c:\file_list.txt) do (
     if "!counter!"=="%1" goto :printme &amp; set /a counter+=1
  )
  :printme
  echo %%a
  </code></pre>
  
  <p>which gives me an output of <code>%a</code>.  Doh!  So, I've tried echoing <code>!a!</code> (result:  <code>ECHO is off.</code>); I've tried echoing <code>%a</code> (result:  a)  </p>
  
  <p>I figured the easy thing to do would be to modify the <code>head.bat</code> code found here:
  <a href="https://stackoverflow.com/questions/130116/dos-batch-commands-to-read-first-line-from-text-file">Windows batch command(s) to read first line from text file</a><br/>
  except rather than echoing every line - I'd just echo the last line found.  Not as simple as one might think.  I've noticed that my counter is staying at zero for some reason; I'm wondering if the <code>set /a counter+=1</code> is doing what I think it's doing.</p>