如何避免延迟扩展删除文件名中的感叹号?
@echo off
Set path="C:\example"
Set chars=a b c
cd /d %path%
setlocal EnableDelayedExpansion
for %%A in (%chars%) do (
set filesList=
for /F "tokens=* delims=" %%B in ('dir %%A^* /a-d /b') do (
set filesList=!filesList!"%%~nxB"
)
if not "!filesList!"=="" (
echo %%A filesList: !filesList!
)
)
endlocal