zh159 兄 dir 之后再 find 的方案仍然有可能找到以 .htm 结尾的文件夹名,因为在 dir 的时候没有用参数过滤掉文件夹,dir 再加个参数 /a-d 就可以省去 find 的步骤了。在2F的基础上修改演示代码如下:
@echo off
for /f "delims=" %%i in ('dir /a-d /b/s d:\html\*.htm') do echo "%%i" "%%il"
pause
Brother zh159, the previous plan of using dir followed by find still might find folder names ending with .htm because dir didn't filter out folders. Adding the parameter /a-d to dir can eliminate the need for find. Modify the demo code based on 2F as follows:
@echo off
for /f "delims=" %%i in ('dir /a-d /b/s d:\html\*.htm') do echo "%%i" "%%il"
pause