本帖最后由 xp3000 于 2021-5-23 06:45 编辑
- @cd /d d:\1\
-
- @echo off & setlocal EnableDelayedExpansion
- for /f "tokens=*" %%i in ('dir /a:d /b *') do (echo 搜索目录"%%i"&echo.
- for /f "delims=" %%j in ('echo %%i^| findstr /i /v "^111 ^222"') do echo 删除非匹配目录"%%j"&echo.&rd "%%j" /s /q
- for /f "delims=" %%k in ('echo %%i^| findstr /i /r /x "^111.* ^222.*"') do (echo 符合要求,即将切换.......
- pushd %%k&echo 切换目录"%%k"
- for /f "delims=" %%l in ('dir /b/a-d/on *.*^| findstr /i /v "^333 ^444"^| findstr /i /v "exe$ ini$"') do (
- echo 搜索到非匹配文件,删除"%%l" & del /f /s /q "%%l"
- )
- popd&echo.退出目录"%%k"&echo.
- rd "%%k" 2>nul&echo 如果"%%k"为空文件夹将删除
- )
- )
- )
- pause
复制代码
|