How to search for line with ConstructionTime(10); in a file and get the number assigned to a variable?
问题 The command find /i "constructiontime" file.cfg outputs the line constructiontime(10); I want to read in this line and get just the number assigned to a variable independent on what is the number value. How can this be done? 回答1: The solution is using command FOR : @echo off set "ConstrutionTime=" for /F "tokens=2 delims=()" %%I in ('%SystemRoot%\System32\find.exe /I "constructiontime" file.cfg') do set "ConstrutionTime=%%I" if defined ConstrutionTime echo The construction time is: