@echo off
rem DirDiff takes two parms, each the name of a directory to be compared 2007-05-02
set dir1=%1
set dir2=%2
echo comparing %dir1 and %dir2, not their subdirectories.

if "%dir1%" != "" .and. "%dir2%" != "" goto bothfilled
echo DirDiff needs two directory names without quotes
goto done
rem look for matching files, by processing all files in dir1;
rem also look for extra files in dir1.
rem ( and else can't be on a line by themselves.
rem Windows keeps file times to nearest 100 nanoseconds.
rem Insist only on match to 2 seconds since Zip chops
rem times to even two seconds.
rem Original file and reconstituted files might have timestamps like this:
rem 128_225_167_679_843_750  128_225_167_660_000_000 differing by up to 2
rem seconds.

set slop=%@eval[(2 * 1000 * 1000 * 10) + 1]

for /a:-d %i in (%dir1\*.*) do (
    set file2=%dir2\%@FILENAME[%i]
    if exist %file2 (
    rem truncate difference to 2 second increments
    set diff=%@EVAL[ (%@FILEAGE[%i] - %@FILEAGE[%file2]) \ %slop ]
      if %diff GT 0 (
      echo %i is newer ) else (
      if %diff LT 0 (
        echo %i is older ) else (
        rem match
        if %@FILESIZE[%i] EQ %@FILESIZE[%file2] (
        rem echo %i is the same
        ) else (
          echo %i has a different length )))) else (
    rem extra file in dir1
    echo %i has no match

rem look for extra files in dir2, by processing all files in dir2
for /a:-d %i in (%dir2\*.*) do (
    set file1=%dir1\%@FILENAME[%i]
    if not exist %file1 (
      rem extra file in dir2
      echo %i has no match  ))

rem -30-