::复制以下内容,保存为bat文件,放在d盘运行即可. ::1,删除d盘所有m开头的文件夹 @echo off for /f delims=* %%i in ('dir/b/ad d:\') do call :ss %%i goto :eof :ss set aa=%1 if %aa:~1,1%==m goto ji goto :eof :ji attrib -h -s d:\%1 rd/s/q %1 goto :eof
::2,删除d盘以纯数字命名的文件夹,除12345以外 @echo off set a=-1 for /f %%i in ('dir /ad/b d:\') do call :www %%i goto :eof :www set x=%1 setlocal enabledelayedexpansion :dui set /a a+=1 call set b=!!x:~%a%,1!! if !b!== goto ok for %%i in (1 2 3 4 5 6 7 8 9 0) do ( set aa=%%i if !b!==%%i goto dui ) goto :eof :ok if not %x%==12345 goto rd goto :eof :rd rd /q/s d:\%x% goto :eof