I would like to use MS-DOS FIND command (or some other method) in a batch to locate a string from TEXTFILE.TXT and store it to a variable. My text file has multiple lines, and the string I search for is always the same "StoreId=" However, it can be on different lines within the text file. Always in the top 10 lines. I am after the value of what StoreId equals for the contents of the variable.
Example line from text file: StoreId=st0028
DOS batch variable contents desired: 0028
@echo off
setlocal
set storeId=
for /f "tokens=1,* delims==" %%a in ('type "%~1" 2^>NUL ^| findstr /i /c:"Storeid="') do if /i "%%a"=="Storeid" set storeId=%%b
echo storeId=%storeId%
Good Luck,
Steve