本帖最后由 Echo11 于 2022-9-23 08:33 编辑
回复 1# andycker
注意计数器不能用n这种单字母,因为你可能把它当作变量了。
最多支持A-Z 26个变量- @ECHO OFF
- setlocal EnableDelayedExpansion
- SET count=9
- SET "10=A"& SET "11=B"& SET "12=C"& SET "13=D"& SET "14=E"& SET "15=F"& SET "16=G"& SET "17=H"& SET "18=I"& SET "19=J"& SET "20=K"& SET "21=L"& SET "22=M"& SET "23=N"& SET "24=O"& SET "25=P"& SET "26=Q"& SET "27=R"& SET "28=S"& SET "29=T"& SET "30=U"& SET "31=V"& SET "32=W"& SET "33=X"& SET "34=Y"& SET "35=Z"
- for /r . %%i in (*.txt) do SET /A count+=1&CALL :SetValue !count! "%%~i"
- ECHO.1、直接按需调用:
- Echo.A:%A%
- Echo.B:%B%
- Echo.C:%C%
- Echo.D:%D%
- Echo..:...
- Echo.Y:%Y%
- Echo.Z:%Z%
- ECHO.
- ECHO.2、按A-Z顺序打印或调用:
- for /L %%i in (10,1,35) do CALL :Print !%%i!
- pause&goto:eof
-
- :SetValue <变量名词典索引> <赋值>
- SET !%~1!=%~2
- goto:eof
-
- :Print <变量>
- Echo.%~1:!%~1!
- goto:eof
复制代码
|