@echo off
rem 本程序用於打印出指定文件夾中最底層的文件夾的列表
rem %1爲需要遍歷的文件夾絕對路徑 %2爲輸出文件的絕對路徑
setlocal enabledelayedexpansion
call :searchDir %1 > %2
goto :EOF
:searchDir
setlocal
for /d %%i in (%1\*) do (
for /f %%j in ('dir /b /a:-d /ad "%%i" ^| find /c /v ""') do (
if %%j == 0 (
echo %%i
) else (
call :searchDir “%%i%“
)
)
)
endlocal