批处理统计某文件夹中文件的个数

@echo off
set cnt=0
for /f "delims=" %%i in ('dir/b/a-d "d:112" 2^>nul') do (set /a cnt+=1
echo %%i
)
if defined cnt (echo,共有%cnt%个文件.) else echo,没有找到文件.
pause

你可以把"D:112"修改成你想要的任何文件夹;例如 :for /f "delims=" %%i in ('dir /b /a-d "%cd%Debug_%timestamp%_*.zip"') do (set /a fCount+=1)
如果希望将”D:112“下的子文件夹下的文件也包含在内的话,在dir后面再加个/s

出处:https://zhidao.baidu.com/question/567068676.html

原文地址:https://www.cnblogs.com/mq0036/p/11351285.html