批处理文件发现语法错误 - 不确定我做错了什么
Batch file find syntax error - not sure what I did wrong
我正在尝试使用 .cmd 比较两个文件的变化。现在,我只需要找到一个小字符串来比较而不是整个文件。
这些文件中的信息紧跟在 "change number : " 之后。如下:
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.
AppID : 346110, change number : 1230200/1230201, token 0, last change : Wed Aug 19 08:36:34 2015
"346110"
在这种情况下,结果应为“1230200/1230201”
这是我尝试使用的代码。
rem Because its SteamCMD we only want to check change numbers as other parts of the file change frequently
for /f "tokens=3 delims=:/" %%a in ('find "change number :" ^< %~n0-latest-version ') do SET "latest=%%a"
for /f "tokens=3 delims=:/" %%a in ('find "change number :" ^< %~n0-current-version ') do SET "current=%%a"
IF NOT %latest% == %current% goto shutdown_server
当 IF NOT %latest% == %current%
行是 运行 时,%latest% 和 %current% 中没有存储任何信息。
我认为我的代码中存在某种语法错误,但我没有看到。有什么建议么?
如果将“/”指定为分隔符,则第二个数字将不会与第一个数字一起提取。这是-非常-硬编码的。
C:>type f-current-version
team API...OK.
AppID : 346110, change number : 1230200/1230201, token 0, last change : Wed Aug 19 08:36:34 2015
"346110"
C:>type f-latest-version
team API...OK.
AppID : 346110, change number : 1230200/1230201, token 0, last change : Wed Aug 19 08:36:34 2015
"346110"
cmd脚本
for /f "tokens=5 delims=:, " %%a in ('find "change number :" ^< %~n0-latest-version ') do SET "latest=%%a"
for /f "tokens=5 delims=:, " %%a in ('find "change number :" ^< %~n0-current-version ') do SET "current=%%a"
echo %latest%
echo %current%
C:>f.bat
1230200/1230201
1230200/1230201
我正在尝试使用 .cmd 比较两个文件的变化。现在,我只需要找到一个小字符串来比较而不是整个文件。
这些文件中的信息紧跟在 "change number : " 之后。如下:
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.
AppID : 346110, change number : 1230200/1230201, token 0, last change : Wed Aug 19 08:36:34 2015
"346110"
在这种情况下,结果应为“1230200/1230201”
这是我尝试使用的代码。
rem Because its SteamCMD we only want to check change numbers as other parts of the file change frequently
for /f "tokens=3 delims=:/" %%a in ('find "change number :" ^< %~n0-latest-version ') do SET "latest=%%a"
for /f "tokens=3 delims=:/" %%a in ('find "change number :" ^< %~n0-current-version ') do SET "current=%%a"
IF NOT %latest% == %current% goto shutdown_server
当 IF NOT %latest% == %current%
行是 运行 时,%latest% 和 %current% 中没有存储任何信息。
我认为我的代码中存在某种语法错误,但我没有看到。有什么建议么?
如果将“/”指定为分隔符,则第二个数字将不会与第一个数字一起提取。这是-非常-硬编码的。
C:>type f-current-version
team API...OK.
AppID : 346110, change number : 1230200/1230201, token 0, last change : Wed Aug 19 08:36:34 2015
"346110"
C:>type f-latest-version
team API...OK.
AppID : 346110, change number : 1230200/1230201, token 0, last change : Wed Aug 19 08:36:34 2015
"346110"
cmd脚本
for /f "tokens=5 delims=:, " %%a in ('find "change number :" ^< %~n0-latest-version ') do SET "latest=%%a"
for /f "tokens=5 delims=:, " %%a in ('find "change number :" ^< %~n0-current-version ') do SET "current=%%a"
echo %latest%
echo %current%
C:>f.bat
1230200/1230201
1230200/1230201