Checks for Duplicate Files

September 23, 2012 at 07:10:48
Specs: Windows 7, Intel Core i7 2.20GHz / 8 GB RAM
Hey everyone, I'm having issues creating a batch file to test a target directoy for duplicate files. I need the batch to immediately begin to duplicating files if no duplicates are found. If there are duplicates, then the files that are duplicates are displayed and action is paused. Then you can decide whether to continue copying or break the batch execution.

If anyone finds the time to help me with this, I'd be very appreciative.Thanks :)

See More: Checks for Duplicate Files

Report •

September 23, 2012 at 07:49:12
Duplicate files in multiple directories? ( I am assuming that you can't have the same file with the same name in the same directory) IF not what kind of Duplicate are you looking for, the file content being the same?

What have you already put together? It sounds like you have a start of the batch script, which part are you having trouble with?

:: mike

Report •

September 25, 2012 at 10:48:16
Thanks for the reply!

Sorry, I should have been more clear. I'm looking to test the target directory and compare it to the directory I'm running the batch file in to test for files that are the same. If there are duplicate files, the batch file is halted and a message is displayed asking whether to halt the process or continue. If there are no duplicate files, then copy the contents of the target directory to a third one named backup. I hope that is more clear.

Sorry for the confusion, I'm still quite new to batch and learning what works and what doesn't. >.<

Edit: Here is what I have so far, it's not quite working yet :/

ECHO Type the directory path you're currently in
set /p d1=
ECHO Type the directory path you would like to check for duplicates
set /p d2=

set dest=G:\Backup

for %%f in (%d2%\*) DO (
if exist %d1% ECHO %%f

GOTO halt

for %%f in (%d1%\*) DO (
if not exist %d2%\%%~nxf copy %%f %dest%

GOTO end

ECHO Duplicate file(s) exist.
ECHO Type 1 to continue copying or 2 to abandon copying
set /p option1=

If %option1%==1 GOTO resume
If %option1%==2 GOTO end

ECHO Finished.

I think I finally may have it working

Report •
Related Solutions

Ask Question