用批处理实现删除大小和类型一样的文件的代码
作者:
用批处理实现删除大小和类型一样的文件的代码
删除大小和类型一样的文件.bat
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=*" %%a in ('dir/a-d/b/oe') do set/a c+=1&set a!c!=%%a&set b!c!=%%~za&set c!c!=%%~xa
for /l %%a in (1,1,%c%) do set/a d=%%a+1&for /l %%b in (!d!,1,%c%) do if not !b%%a!.==. call :1 %%a %%b
goto :eof
:1
if !b%1!==!b%2! if !c%1!==!c%2! set b%2=&del "!a%2!"
goto :eof
复制代码 代码如下:
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=*" %%a in ('dir/a-d/b/oe') do set/a c+=1&set a!c!=%%a&set b!c!=%%~za&set c!c!=%%~xa
for /l %%a in (1,1,%c%) do set/a d=%%a+1&for /l %%b in (!d!,1,%c%) do if not !b%%a!.==. call :1 %%a %%b
goto :eof
:1
if !b%1!==!b%2! if !c%1!==!c%2! set b%2=&del "!a%2!"
goto :eof