- @Echo Off
- title 删除所有空目录
- SETLOCAL ENABLEDELAYEDEXPANSION
- @echo 删除所有空目录(含子目录)
- @echo -----------------------------
- @ set /p GTOperator="继续操作吗?(yes/no) "
- if /i "%GTOperator:~0,1%"=="y" (
- goto GTCONTINUE
- ) else ( goto GTExit )
- :GTCONTINUE
- for /f "delims=" %%i in ('dir /ad /b /s') do call :RdEmptyDir "%%i"
- goto :eof
- :RdEmptyDir
- rd %1 2>nul||goto :eof
- set DirPath=%1
- for /f "delims=" %%i in (%DirPath%) do (
- set DirPath="%%~dpi"
- for /f "delims=" %%j in ('dir /ad /b "%%~dpi"')do rd "%%~dpi%%j" 2>nul||goto :eof
- )
- if "%DirPath:~-2,1%"=="\" set DirPath="%DirPath:~1,-2%"
- if /i not "%cd%"==%DirPath% call :RdEmptyDir %DirPath%
- goto :eof
-
- :GTExit
- exit
复制代码
|