So for the second part of my current dilemma, I have a list of folders in c:\file_list.txt
. 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.
@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 & set /a counter+=1
)
:printme
echo %%a
which gives me an output of %a
. Doh! So, I've tried echoing !a!
(result: ECHO is off.
); I've tried echoing %a
(result: a)
I figured the easy thing to do would be to modify the head.bat
code found here:
http://stackoverflow.com/questions/130116/dos-batch-commands-to-read-first-line-from-text-file
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 set /a counter+=1
is doing what I think it's doing.