計算各子資料夾檔案數量

@echo off > newfile.txt & setLocal enableDELAYedeXpansion

For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set date=%%a-%%b-%%c)

For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set time=%%a%%b)

set Name=%date%_%time%


set /p From="輸入欲計算資料夾內檔案數量的路徑:"
set curr=%CD%
pushd """%From%"""

for /f "tokens=* delims= " %%a in ('dir/s/b/ad') do (

pushd "%%a"

set N=0

for /f "tokens=* delims= " %%f in ('dir/b/a-d 2^>nul') do (

set /a N+=1

)

if !N! neq 0 (

echo %%a有 !N!個檔案>> "!curr!\newfile.txt"

)

)

rename "!curr!\newfile.txt" %Name%.txt

start !curr!\%Name%.txt
rename "!curr!\newfile.txt" %Name%.txt start !curr!\%Name%.txt

END

張貼留言

較新的 較舊

نموذج الاتصال