我得到了两个txt文件“ test-exclamations !!!。txt”,“ test-normal.txt”,一个bat文件在同一文件夹中包含以下脚本。
ECHO OFF & CLS
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=* delims=" %%a IN ('dir /b *.txt') DO (
set /a count=count+1
echo !count!:%%a
)
ENDLOCAL
EXIT/B
我得到的结果是:
1:test-exclamations.txt
2:test-normal.txt
我们可以看到感叹号消失了。
我有一些方法可以从Internet上保留感叹号,但不能同时保留感叹号和变量“ count ”的值。
请告诉我如何同时保留两者。
@ECHO OFF
setlocal enableextensions disabledelayedexpansion
FOR /F "tokens=* delims=" %%a IN ('dir /b *.txt') DO (
set /a "count+=1"
set "file=%%a"
setlocal enabledelayedexpansion
echo !count!:!file!
endlocal
)
endlocal
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句