你自行测试一下, 确认无误后, 再把 echo del 那行改成实际的删除代码- @echo off
- setlocal enabledelayedexpansion
- set /a "deltotal=id=0"
- for /f "delims=" %%a in ('dir *?-*?-*?-*?-*?-*?-*?.dxf /o-d /b /s') do (
- for /f "tokens=1-6 delims=-" %%b in ("%%~na") do (
- if "!$%%~spa%%b-%%c-%%d-%%e-%%f-%%g!"=="" (
- set /a id+=1
- set "$%%~spa%%b-%%c-%%d-%%e-%%f-%%g=!id!"
- ) else (
- set /a "@!$%%~spa%%b-%%c-%%d-%%e-%%f-%%g!+=1, deltotal+=1"
- echo del /f /q "%%a"
- )
- )
- )
- echo;
- for /f "delims==" %%a in ('set $') do (
- echo %%a
- for %%b in (@!%%a!) do echo 删除了 !%%b! 个文件 & echo;
- )
- echo; & echo 总计删除了 !deltotal! 个文件
- pause
复制代码
|