一种方法(读取每一行,=
将 lhs/rhs 定界并捕获到%%A
& %%B
);
@echo off
setlocal EnableDelayedExpansion
for /F "eol= tokens=1,2 delims==," %%A in (the.file) do (
if "%%A"=="VERSION" (
set version=%%B
) else if "%%A"=="CS_VERSION" (
set cs_version=%%B
)
)
echo VERSION is %version%
echo CS_VERSION is %cs_version%
测试;
@echo off
@(
echo 1
echo 2
echo 3
echo 4
echo 5
echo 6
echo 7
echo 8
echo 9
echo 10
echo 11
echo 12
echo 13
echo 14
echo 15
echo 16
echo 17
echo VERSION=6.0.196.0
echo CS_VERSION=6.0
) > the.file
setlocal EnableDelayedExpansion
for /F "eol= tokens=1,2 delims==, skip=17" %%A in (the.file) do (
if "%%A"=="VERSION" (
set version=%%B
) else if "%%A"=="CS_VERSION" (
set cs_version=%%B
)
)
echo VERSION is %version%
echo CS_VERSION is %cs_version%