If you want to just match on name, date (which one?), and size, I can modify the command file easily enough. I'll look at it in a few hours.
Probably also get it to spit out a command file to do the moving of matching files.
Not far different from the
original.
EDIT: New version, old one is still above.
Compares Size, Date, Name, and optionally compares binaries.
Generates a logfile that includes the commands to copy or move the duplicates to another directory using Robocopy, (duplicates folder tree). Files from the 2nd chosen directory are the sacrificial victims.
@if (@CodeSection == @Batch) @then
@echo off
color 1a
setlocal EnableExtensions
setlocal DisableDelayedExpansion
echo Select PRIMARY folder
for /F "delims=" %%S in ('CScript //nologo //E:JScript "%~F0"') do (
set srce=%%S
)
if "%srce%"=="" goto :End2
echo Selected folder: "%srce%"
echo Select folder to COMPARE
for /F "delims=" %%D in ('CScript //nologo //E:JScript "%~F0"') do (
set dest=%%D
)
if "%dest%"=="" goto :End2
echo Selected folder: "%dest%"
if "%srce%"=="%dest%" goto :End1
echo.
echo The following prompt asks you for a folder to move duplicates to.
echo.
echo ---- HOWEVER, THIS COMMAND FILE DOES NOT MOVE THEM ----
echo.
echo The path is written to the logfile so it can be run separately if
echo required.
echo.
echo Select folder to MOVE duplicates to
for /F "delims=" %%S in ('CScript //nologo //E:JScript "%~F0"') do (
set mdest=%%S
)
if "%mdest%"=="" goto :End2
echo Selected folder: "%mdest%"
set /P como=Copy or Move Duplicates (Set in logfile) [ENTER = Copy]:
echo.
echo If you just want to match on Size, Date, and Name just hit
echo ENTER at the next prompt.
echo If you want to do a binary compare also, enter any character.
echo.
set /P cbin=Do binary compare [ENTER = No]:
:GetExt
echo.
set /P ext=Please enter extension [eg. jpg, * = ALL] ENTER to exit:
if not defined ext goto :End2
set /a totfiles=0
set /a matchfiles=0
call :SetLogfile %~dp0%
echo @echo off >"%logfile%"
echo echo %date% %time% >>"%logfile%"
for /r "%srce%" %%a in (*.%ext%) do (call :CheckSize "%dest%" %%~za "%%~fa")
:End
echo Total files: %totfiles%
echo Matching files: %matchfiles%
if %matchfiles% equ 0 (echo Matching files: 0 >>"%logfile%")
set totfiles=
set matchfiles=
set ext=
if exist "%logfile%" call :ViewLog
goto :GetExt
:End1
color 1c
echo **** SOURCE and DESTINATION are the same! ****
:End2
set srce=
set dest=
pause
rem exit
:SetLogfile
set "logfile=%~1FCompare-%time:~0,2%%time:~3,2%%time:~6,2%.cmd"
goto :EOF
:ViewLog
set /p view=View logfile [y,n]
if "%view%"=="y" (start notepad.exe "%logfile%")
set view=
goto :EOF
:CheckSize
set /a totfiles+=1
for /r %1 %%b in (*.%ext%) do (
if %2==%%~zb (
echo.
echo Comparing: "%~3" "%%~b"
echo Sizes: Match
call :CheckDate "%~3" "%%~b"
)
)
goto :EOF
:CheckDate
if "%~t1" equ "%~t2" (
echo Dates: Match
call :CheckName "%~1" "%~2"
)
goto :EOF
:CheckName
if "%~nx1" equ "%~nx2" (
echo Names: Match
if not defined cbin (
call :Matching "%~1" "%~2"
) else (
call :CheckBin "%~1" "%~2"
)
)
goto :EOF
:CheckBin
.\cmp.exe -s "%~1" "%~2"
if errorlevel 0 (
echo Binaries: Match
call :Matching "%~1" "%~2"
)
goto :EOF
:Matching
set /a matchfiles+=1
echo echo "%~1" matches "%~2" >>"%logfile%"
set tdir=%~dp2
set tdir=%tdir:~0,-1%
set tdir2=%tdir:~2%
if not defined como (
echo robocopy "%tdir%" "%mdest%%tdir2%" "%~nx2" >>"%logfile%"
) else (
echo robocopy "%tdir%" "%mdest%%tdir2%" "%~nx2" /MOV >>"%logfile%"
)
echo.
goto :EOF
endlocal
End of Batch section
@end
// JScript section
// Creates a dialog box that enables the user to select a folder and display it.
var title = "Select a folder", rootFolder = 0x11;
var shl = new ActiveXObject("Shell.Application");
var folder = shl.BrowseForFolder(0, title, 0, rootFolder);
WScript.Stdout.WriteLine(folder ? folder.self.path : "");
Sample output with Move option.
@echo off
echo Wed 29/10/2014 12:53:49.64
echo "R:\test\Root\SimpleBackup.cmd" matches "D:\Root\SimpleBackup.cmd"
robocopy "D:\Root" "D:\test\Root" "SimpleBackup.cmd" /MOV
echo "R:\test\Root\fred h\1234\Hunters & Collecters - Holy Grail.mp3" matches "D:\Root\fred h\1234\Hunters & Collecters - Holy Grail.mp3"
robocopy "D:\Root\fred h\1234" "D:\test\Root\fred h\1234" "Hunters & Collecters - Holy Grail.mp3" /MOV
echo "R:\test\Root\fred h\34\cache\Don McLean - American Pie.mp3" matches "D:\Root\fred h\34\cache\Don McLean - American Pie.mp3"
robocopy "D:\Root\fred h\34\cache" "D:\test\Root\fred h\34\cache" "Don McLean - American Pie.mp3" /MOV
NOTE:If you want another free program, I heartily recommend
Duplicate File Finder by Rashid Hoda - it has best layout for a dupe checker I have ever seen, all the options are right in front of you without having to screw around in menus.
Hasn't been updated in years but the only problem I've found with it is if you have a rather large number of files to check, eg. 40k+
