Source: geocities.com/mrnopersonality/Text

               ( geocities.com/mrnopersonality)    
@ECHO OFF

IF "%~1"=="" GOTO :syntax
IF "%~1"=="/?" GOTO :syntax
IF "%~1"=="--help" GOTO :syntax
IF "%~1"=="--usage" GOTO :syntax
IF "%~1"=="-h" GOTO :syntax
IF "%~1"=="/h" GOTO :syntax
IF "%~1"=="/H" GOTO :syntax
IF "%~2"=="" GOTO :syntax
IF NOT "%~3"=="" IF /I NOT "%~3"=="--recurse" GOTO :syntax
GOTO :compare

:no_source
ECHO "%~1": no such folder
GOTO :EOF

:no_destination
ECHO "%~2": no such folder
GOTO :EOF

:syntax
ECHO Syntax:
ECHO   %0 foldername dupfolder
ECHO where.
ECHO     foldername  is the name of the source folder to compare
ECHO     dupfolder   is the name of the destination folder
GOTO :folder_done

:generate_compare_function
SETLOCAL
SET dircomp_supress_output=">>nul"
SET dircomp_error_output=">>"%TEMP%\dircomp_diff.txt""
SET dircomp_old_error_output=">>"%TEMP%\dircomp_old_items.txt""
SET dircomp_new_error_output=">>"%TEMP%\dircomp_new_items.txt""
SET dircomp_check_exists=
SET dircomp_search_path=

REM Check arguments
SET dircomp_search_path=%~f1
SET dircomp_check_exists=
FOR %%i IN (".") DO IF NOT "%%~$dircomp_search_path:i"=="" GOTO :check_dest
GOTO :no_source

:check_dest
SET dircomp_search_path=%~f2
SET dircomp_check_exists=
FOR %%i IN (".") DO IF NOT "%%~$dircomp_search_path:i"=="" GOTO :args_checked
GOTO :no_destination

:args_checked

REM Count lenght of arguments. This length will be substracted from absolute paths of all files compared
SET dircomp_src=%~1
SET dircomp_src_length=0

:source_char
SET dircomp_short_source=%dircomp_src:~1%
SET /A dircomp_src_length=dircomp_src_length+1
IF "%dircomp_short_source%"=="" GOTO :count_dest
SET dircomp_src=%dircomp_short_source%
GOTO :source_char

:count_dest
SET dircomp_dst=%~2
SET dircomp_dst_length=0

:dest_char
SET dircomp_short_dest=%dircomp_dst:~1%
SET /A dircomp_dst_length=dircomp_dst_length+1
IF "%dircomp_short_dest%"=="" GOTO :generate_batches
SET dircomp_dst=%dircomp_short_dest%
GOTO :dest_char


:generate_batches
SET /A dircomp_src_length=dircomp_src_length+1
SET /A dircomp_dst_length=dircomp_dst_length+1

REM Generate compare batch
FOR %%s IN (%dircomp_supress_output%) DO ECHO fc /B "%%~1" "%%~2" %%~s>"%TEMP%\dircomp_fc.bat"
ECHO SET modified=%%ERRORLEVEL%%>>"%TEMP%\dircomp_fc.bat"
ECHO IF ERRORLEVEL 1 SET dircomp_local_fname=%%~1>>"%TEMP%\dircomp_fc.bat"
ECHO IF ERRORLEVEL 1 SET dircomp_local_fname=%%dircomp_local_fname:~%dircomp_src_length%%%>>"%TEMP%\dircomp_fc.bat"
ECHO IF ERRORLEVEL 1 SET "src_file_new_mark= ">>"%TEMP%\dircomp_fc.bat"
ECHO IF ERRORLEVEL 1 SET "dst_file_new_mark= ">>"%TEMP%\dircomp_fc.bat"
ECHO IF ERRORLEVEL 1 FOR /F %%%%n IN ('xcopy /G /L /D /Q /R /Y "%%~1" "%%~2"') DO IF "%%%%n"=="1" (SET src_file_new_mark=*) ELSE (FOR /F %%%%m IN ('xcopy /G /L /D /Q /R /Y "%%~2" "%%~1"') DO IF "%%%%m"=="1" SET dst_file_new_mark=*)>>"%TEMP%\dircomp_fc.bat"
ECHO IF "%%modified%%"=="1" SET "timestamps=	    %%~t1 %%src_file_new_mark%%   %%~t2 %%dst_file_new_mark%%">>"%TEMP%\dircomp_fc.bat"
FOR %%s IN (%dircomp_error_output%) DO ECHO IF "%%modified%%"=="1" ECHO %%timestamps%%  %%dircomp_local_fname%% %%~s>>"%TEMP%\dircomp_fc.bat"
REM ECHO dircomp_fc.bat:
REM TYPE "%TEMP%\dircomp_fc.bat%
REM exit /b 1

REM Generate search batch
ECHO SET dircomp_search_path=%%~1>"%TEMP%\dircomp_folder_exists.bat"
ECHO IF "%%~$dircomp_search_path:2"=="" GOTO :not_found>>"%TEMP%\dircomp_folder_exists.bat"
ECHO SET dircomp_check_exists=exists>>"%TEMP%\dircomp_folder_exists.bat"
ECHO GOTO :EOF>>"%TEMP%\dircomp_folder_exists.bat"
ECHO. >>"%TEMP%\dircomp_folder_exists.bat"
ECHO :not_found>>"%TEMP%\dircomp_folder_exists.bat"
ECHO SET dircomp_check_exists=>>"%TEMP%\dircomp_folder_exists.bat"
REM TYPE "%TEMP%\dircomp_folder_exists.bat"
REM EXIT /B 1

REM Generate processor batch
ECHO CALL "%%TEMP%%\dircomp_folder_exists.bat" "%%~2" "%%~3" "%%~4">"%TEMP%\dircomp_process_entry.bat"
ECHO IF /I NOT "%%dircomp_check_exists%%"=="exists" GOTO :not_found>>"%TEMP%\dircomp_process_entry.bat"
ECHO. >>"%TEMP%\dircomp_process_entry.bat"
ECHO IF /I "%%~4"=="file" CALL "%%TEMP%%\dircomp_fc.bat" "%%~1\%%~3" "%%~2\%%~3">>"%TEMP%\dircomp_process_entry.bat"
ECHO IF /I "%%~4"=="dir"  CALL "%%~5" "%%~1\%%~3" "%%~2\%%~3" "%%~6">>"%TEMP%\dircomp_process_entry.bat"
ECHO GOTO :EOF>>"%TEMP%\dircomp_process_entry.bat"
ECHO. >>"%TEMP%\dircomp_process_entry.bat"
ECHO :not_found>>"%TEMP%\dircomp_process_entry.bat"
ECHO SET dircomp_local_fname=%%~1\>>"%TEMP%\dircomp_process_entry.bat"
ECHO SET dircomp_local_fname=%%dircomp_local_fname:~%dircomp_src_length%%%>>"%TEMP%\dircomp_process_entry.bat"
FOR %%i IN (%dircomp_old_error_output%) DO ECHO IF /I "%%~4"=="dir"  ECHO 	%%dircomp_local_fname%%%%~3\%%~i>>"%TEMP%\dircomp_process_entry.bat"
FOR %%i IN (%dircomp_old_error_output%) DO ECHO IF /I "%%~4"=="file" ECHO 	%%dircomp_local_fname%%%%~3%%~i>>"%TEMP%\dircomp_process_entry.bat"
REM ECHO dircomp_process_entry.bat
REM TYPE "%TEMP%\dircomp_process_entry.bat">dircomp_process_entry.bat
REM ECHO.

REM Generate reporting batch
ECHO CALL "%%TEMP%%\dircomp_folder_exists.bat" "%%~1" "%%~3" "%%~4">"%TEMP%\dircomp_report_entry.bat"
ECHO SET dircomp_local_fname=%%~2\>>"%TEMP%\dircomp_report_entry.bat"
ECHO SET dircomp_local_fname=%%dircomp_local_fname:~%dircomp_dst_length%%%>>"%TEMP%\dircomp_report_entry.bat"
FOR %%i IN (%dircomp_new_error_output%) DO ECHO IF /I NOT "%%dircomp_check_exists%%"=="exists" IF "%%~4"=="dir"  ECHO 	%%dircomp_local_fname%%%%~3\%%~i>>"%TEMP%\dircomp_report_entry.bat"
FOR %%i IN (%dircomp_new_error_output%) DO ECHO IF /I NOT "%%dircomp_check_exists%%"=="exists" IF "%%~4"=="file" ECHO 	%%dircomp_local_fname%%%%~3%%~i>>"%TEMP%\dircomp_report_entry.bat"
REM ECHO dircomp_report_entry.bat
REM TYPE "%TEMP%\dircomp_report_entry.bat">dircomp_report_entry.bat
REM ECHO.
GOTO :post_generate

:compare
IF NOT "%~3"=="--recurse" GOTO :generate_compare_function
:post_generate

for /D %%d in ("%~1\*") DO CALL "%TEMP%\dircomp_process_entry.bat" "%~1" "%~2" "%%~nd%%~xd" "dir"  "%~0" "--recurse"
for /D %%d in ("%~2\*") DO CALL "%TEMP%\dircomp_report_entry.bat"  "%~1" "%~2" "%%~nd%%~xd" "dir"  "%~0" "--recurse"
for %%f in ("%~1\*") DO    CALL "%TEMP%\dircomp_process_entry.bat" "%~1" "%~2" "%%~nf%%~xf" "file" "%~0"
for %%f in ("%~2\*") DO    CALL "%TEMP%\dircomp_report_entry.bat"  "%~1" "%~2" "%%~nf%%~xf" "file" "%~0"

:folder_done
IF /I "%~3"=="--recurse" GOTO :EOF

REM Display results and clean up files in %TEMP%
del "%TEMP%\dircomp_report_entry.bat"
del "%TEMP%\dircomp_process_entry.bat"
del "%TEMP%\dircomp_folder_exists.bat"
REM IF NOT EXIST %TEMP%\dircomp_diff.txt ECHO Done.
IF EXIST %TEMP%\dircomp_diff.txt ECHO Modified:
IF EXIST %TEMP%\dircomp_diff.txt TYPE "%TEMP%\dircomp_diff.txt"
IF EXIST %TEMP%\dircomp_diff.txt ECHO.
IF EXIST %TEMP%\dircomp_diff.txt DEL "%TEMP%\dircomp_diff.txt"
IF EXIST %TEMP%\dircomp_old_items.txt ECHO Only in %~1:
IF EXIST %TEMP%\dircomp_old_items.txt TYPE "%TEMP%\dircomp_old_items.txt"
IF EXIST %TEMP%\dircomp_old_items.txt ECHO.
IF EXIST %TEMP%\dircomp_old_items.txt DEL  "%TEMP%\dircomp_old_items.txt"
IF EXIST %TEMP%\dircomp_new_items.txt ECHO Only in %~2:
IF EXIST %TEMP%\dircomp_new_items.txt TYPE "%TEMP%\dircomp_new_items.txt"
IF EXIST %TEMP%\dircomp_new_items.txt ECHO.
IF EXIST %TEMP%\dircomp_new_items.txt DEL  "%TEMP%\dircomp_new_items.txt"

del "%TEMP%\dircomp_fc.bat"
SET dircomp_check_exists=
SET dircomp_error_output=
SET dircomp_supress_output=
ENDLOCAL
ECHO.