Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
This forum has been extremely helpful to me and I wanted to share this batch file.
It was created by Leonardo (aka Secret_Doom) and I want to thank him immensely for his help.As noted in his file, this batch file will work with both Win98 and WinNT. It compares the files in DIR1 to DIR2. If duplicates are found, it removes the duplicate from each and places it in DIR3.
:: -----
:: Author: Leonardo Pignataro (secret_doom@hotmail.com)
::
:: Compare filenames from %DIR1% and %DIR2%, place a copy
:: of the matches on %DIR3% and delete originals.
::
:: Designed and tested under:
:: Windows 98 Second Edition and Windows XP Professional
:: -----
@echo off
if "%1"=="GoTo" GOTO %2
%comspec% /E:2048 /C %0 GoTo start
goto eof
:start:: Set directories below. Use short names (e.g.: c:\progra~1)
set DIR1=C:\DIR1
set DIR2=C:\DIR2
set DIR3=C:\DIR3if "%OS%"=="Windows_NT" goto NT
XCOPY /I/L/N/U/Y %DIR1%.\*.* %DIR2% |FIND/v " " > %temp%.\T1.BAT
echo e100'SET %%1='> %temp%\T3.DAT
for %%? in (rcx 7 w q) do echo %%?>> %temp%.\T3.DAT
type nul> %temp%.\T2.DAT
DEBUG %temp%.\T2.DAT nul:loop
copy %temp%.\T1.BAT nul > %temp%.\T3.DAT
FIND " 0 " nul
if not errorlevel=1 goto loopend
copy/y %temp%.\T2.DAT+%temp%.\T1.BAT %temp%.\T3.DAT > nul
FIND "SET %%1=" %temp%.\T1.BAT
call %temp%.\T1.BAT FILE
echo Duplicate found - %FILE%
copy %DIR1%.\%FILE% %DIR3% > nul
for %%? in (%DIR1% %DIR2%) do del %%?.\%FILE%
FIND/V "SET %%1=" %temp%.\T1.BAT
goto loop:loopend
for %%? in (T1.BAT T2.DAT T3.DAT) do del %temp%.\%%?
goto eof:NT
for %%? in (%DIR1%\*.*) do (
if exist %DIR2%\%%~nx? (
echo Duplicate found - %%~nx?
copy %%? %DIR3% > nul
del %%?
del %DIR2%\%%~nx?
)
):eof
------------------------
Thanks!
-aml

Thanks for the credit. However, the script was modifyed because of post problems (besides, some lines wrapped). Below is the full working script (the script you posted won't do what it should).
===== BATCH SCRIPT BEGIN =====
:: -----
:: Author: Leonardo Pignataro (secret_doom@hotmail.com)
::
:: Compare filenames from %DIR1% and %DIR2%, place a copy
:: of the matches on %DIR3% and delete originals.
::
:: Designed and tested under:
:: Windows 98 Second Edition and Windows XP Professional
:: -----
@echo off
if "%1"=="GoTo" GOTO %2
%comspec% /E:2048 /C %0 GoTo start
goto eof
:start:: Set directories below. Use short names (e.g.: c:\progra~1)
set DIR1=C:\DIR1
set DIR2=C:\DIR2
set DIR3=C:\DIR3if "%OS%"=="Windows_NT" goto NT
XCOPY /I/L/N/U/Y %DIR1%.\*.* %DIR2% |FIND/v " " > %temp%.\T1.BAT
echo e100'SET %%1='> %temp%\T3.DAT
for %%? in (rcx 7 w q) do echo %%?>> %temp%.\T3.DAT
type nul> %temp%.\T2.DAT
DEBUG %temp%.\T2.DAT < %temp%.\T3.DAT > nul:loop
copy %temp%.\T1.BAT nul > %temp%.\T3.DAT
FIND " 0 " < %temp%.\T3.DAT > nul
if not errorlevel=1 goto loopend
copy/y %temp%.\T2.DAT+%temp%.\T1.BAT %temp%.\T3.DAT > nul
FIND "SET %%1=" < %temp%.\T3.DAT > %temp%.\T1.BAT
call %temp%.\T1.BAT FILE
echo Duplicate found - %FILE%
copy %DIR1%.\%FILE% %DIR3% > nul
for %%? in (%DIR1% %DIR2%) do del %%?.\%FILE%
FIND/V "SET %%1=" < %temp%.\T3.DAT > %temp%.\T1.BAT
goto loop:loopend
for %%? in (T1.BAT T2.DAT T3.DAT) do del %temp%.\%%?
goto eof:NT
for %%? in (%DIR1%\*.*) do (
if exist %DIR2%\%%~nx? (
echo Duplicate found - %%~nx?
copy %%? %DIR3% > nul
del %%?
del %DIR2%\%%~nx?
)
):eof
===== BATCH SCRIPT END =====-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br__________________________________________________________________

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |