Reputation: 49
i have a long game config and i want to make an overview as a batch screen.
What i"m trying to do, is that the batch script looks at a specified line and then picks an info.
Ex :
Tax Rate : 15
Admin Rate : 20
Mod Rate : 18
I'd want the script to look in line 2 after the 13 digits (Admin Rate :
) and set the outut as a variable.
Such as
for /f in delim=2;13 in ('config.yml') do set adminrate
So at the end i can output clearly all the configs.
echo Admin Rate : %adminrate%
Upvotes: 0
Views: 129
Reputation: 41307
This just selects the 2nd line, if that is needed.
EDITED to return the entire line.
@echo off
for /f "tokens=1,* delims=]" %%a in ('find /n /v "" ^< "config.txt" ^| findstr "^\[2\]" ') do set "variable=%%b"
echo "%variable%"
pause
Note that if the selected line starts with ] characters then they will be removed from the string.
Upvotes: 1
Reputation: 37589
try this:
for /f "tokens=3delims=: " %%a in ('findstr /c:"Admin Rate" "config.yml"') do set "adminrate=%%a"
echo(%adminrate%
Upvotes: 2