|
|
发表于 2019-3-8 20:40:07
|
显示全部楼层
回复 6# locoman
用bat也许更好,下面纯批处理,请保存为 文件名.bat- @echo off
- setlocal EnableDelayedExpansion
- REM 设置要排除的目录列表,用双引号包括,以空格分割.
- set dirsExclude="c:\windows" "d:\办公保存" "e:\档案保存"
- REM 要删除的文件扩展名列表,用双引号包括,以空格分割.
- set exts="*.xls" "*.doc" "*.jpg"
- echo 全盘搜索中,请稍候...
- for /f "tokens=1*" %%A in ('fsutil fsinfo drives') do (
- for %%D in (%%B) do (
- pushd "%%D"
- for /f "delims=" %%E in ('dir /ad-h-s /b') do (
- set flag=1
- for %%F in (%dirsExclude%) do (
- if /i "%%~fE"==%%F set flag=0
- )
- if !flag!==1 (
- for /f "delims=" %%G in ('where /r "%%~fE" /f %exts% 2^>nul') do (
- REM 若要真正删除文件,请去掉下面这行的 "echo"
- echo del /f /q %%G
- )
- )
- )
- popd
- )
- )
- )
- endlocal
- pause
- exit /b
复制代码 |
|