dbe*_*ham 14
@echo off
for /d /r %1 %%A in (.) do (
dir /a /b "%%~fA" 2>nul | findstr "^" >nul || echo %%~fA
)
Run Code Online (Sandbox Code Playgroud)
上述解决方案忽略了隐藏文件夹.我也被告知,对FOR使用/ D和/ R选项都会被窃听,尽管我从未遇到过问题.
@echo off
dir /a /b %1 2>nul | findstr "^" >nul || echo %%~fA
for /f "eol=: delims=" %%A in ('dir /s /ad /b %1') do (
dir /a /b "%%~fA" 2>nul | findstr "^" >nul || echo %%~fA
)
Run Code Online (Sandbox Code Playgroud)
避免FOR/D/R的第二个解决方案将包括隐藏文件夹.但我相信如果文件夹名称包含Unicode,它可能会失败.