- @echo off
- REM 目标文件夹
- set "folder=C:\Users\lenovo\Desktop\新建文件夹"
- REM 排除的字符串
- set "key=你好"
- REM 开始删除
- for /f "delims=" %%i in ('dir /s /b /a-d "%folder%"') do (
- echo %%~ni | findstr "%key%" >nul 2>nul || (
- echo 删除 %%i
- del /f /q "%%~i"
- )
- )
- pause&exit
复制代码 ANSI编码,先测试再用 |