我正在尝试将整数文件夹名称与变量进行比较。文件夹名称都是整数值。例如,在文件夹“VersionedFolders”中存在子文件夹“95”、“96”,最多“100”。
我的脚本如下:
@echo off
setlocal ENABLEDELAYEDEXPANSION
SET %PATH_TO_VERSION_FOLDER=VersionedFolders
SET %CurrentVersion = 99
for /f %%a in ('dir /B "%PATH_TO_VERSION_FOLDER%"') do (
if %CurrentVersion% LEQ %%a (
echo CurrentVersion !CurrentVersion! is less than or equal to %%a.
set CurrentVersion=%%a
) else (
echo CurrentVersion !CurrentVersion! is not less than or equal to %%a
)
)
输出如下:
CurrentVersion 99 is less than or equal to 100.
CurrentVersion 100 is not less than or equal to 95.
CurrentVersion 100 is not less than or equal to 96.
CurrentVersion 100 is not less than or equal to 97.
CurrentVersion 100 is not less than or equal to 98.
CurrentVersion 100 is less than or equal to 99.
最后一次迭代是自 100 > 99 以来存在问题的地方。
注意 dir /B "%PATH_TO_VERSION_FOLDER%" 的输出是
100
95
96
97
98
99
任何想法为什么“如果 100 LEQ 99”返回真实?