- @echo off
- setlocal EnableDelayedExpansion
- REM 设置要排除的目录列表,用双引号包括,以空格分割.
- set dirsExclude="c:\windows" "d:\办公保存" "e:\档案保存"
- REM 要删除的文件扩展名列表,用双引号包括,以空格分割.
- set exts="*.xls" "*.doc" "*.jpg"
- REM 设置保存文件路径
- set outFile="d:\DEL_list.txt"
- 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 (
- echo %%G
- )
- )
- )
- popd
- )
- )
- )>%outFile%
- endlocal
- pause
- exit /b
复制代码 设备未就绪,可能是有移动USB硬盘把 |