批處理統計某文件夾中文件的個數

@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後面再加個/shtml

 

 

出處:https://zhidao.baidu.com/question/567068676.htmlhtm

相關文章
相關標籤/搜索