I'm quite new to batch command and I really need your help. I have a Config.ini file, at the end of every group or [bracket] it always separated by an empty line like this:
------------- Begin of Config.ini
------------- End of Config.ini (19 lines)
If a list is active, it will be marked by "Default" variable followed by "1" string. Otherwise it will be left empty without "Default" variable and also without "1" string.
This Config.ini only have one "Default" variable, it could move to another list if switched through main application.
Anyway, in this case the "Default=1" is n, and will always be. I need a batch file which could echo variable value only from n-1 line which is "Bart.folder" string.
Here is my attempt:
------------- Begin of DeFolder.bat
for /f "tokens=1 delims=:" %%A in ('type Config.ini ^| findstr /r /b /i /n /c:"Default=1"') do (
set /a A=%%A
set /a B=%%A%-1
echo Default variable / n is line: %A%
echo Folder variable / n-1 is line: %B%
echo "I wish I could echo variable value from line 7 here. Unexpected output when batch below is executed, no more empty line separators."
for /f "tokens=* delims= " %%C in (Config.ini) do (
set /a n+=1
echo Line1: %line1%
echo Line2: %line2%
echo Line3: %line3%
echo Line4: %line4%
echo Line5: %line5%
echo Line6: %line6%
echo Line7: %line7%
echo Line8: %line8%
echo Line9: %line9%
echo Line10: %line10%
echo Line11: %line11%
echo Line12: %line12%
echo Line13: %line13%
echo Line14: %line14%
echo Line15: %line15%
echo Line16: %line16%
echo Line17: %line17%
echo Line18: %line18%
echo Line19: %line19%
echo "Output above doesn't contain any empty line separators. So n-1 formula is not applicable anymore. Why?"
for /f "tokens=2 delims==" %%D in ('type Config.ini ^| findstr /r /b /i /n /c:"Folder="') do (
echo Folder: %%~nxD
echo "All I need is output like this, but from 7th line only. Just "Bart.folder", not all."
------------- End of DeFolder.bat
I spend countless hours doing it but I cannot seem to find anything. If anyone can help, it would greatly be appreciated. Thanks in advance.