@echo off :: Test for delayed environment set test=foo for %%x in (1 2 3) do set test=!test!%%x if %test%==foo123 goto OKAY cls echo This batch file will DELETE duplicate files in it's directory. echo. echo You MUST run this batch file in a delayed environment. echo start a session like this: echo CMD /V:ON echo. pause goto DONE :OKAY set oldsize=0 set fnamenew=foo for /f %%x in ('dir /os /b *.*') do call :PROC %%x goto DONE :PROC set fnameold=!fnamenew! set fnamenew=%1 for /f "tokens=3 delims= " %%x in ('dir %1 ^| find "/"') do set newsize=%%x call :CMP "%oldsize%" "%newsize%" %1 goto DONE :CMP echo %2 %3 if [%1]==[%2] call :HIT set oldsize=!newsize! goto DONE :HIT fc %fnamenew% %fnameold% | find "no differences" if not errorlevel 1 del %fnameold% goto DONE :DONE