Charles, the code as you've written it is more like a subroutine than a FUNCTION. Subroutines are accessed by GOSUB.
Have you considered downloading the free tool WinMerge? It allows you to compare individual files as well as entire directory trees.
Here is my take on a solution for you:
rem returns 1 if files are identical, 0 otherwise
rem returns a relative path
rem convert relative input paths to full paths
rem iterate over all the files from the source tree
do f in /a:-d /d"%f1" /s *
rem files are names only in a DO loop. Convert to full path
rem convert the full path into a relative path and prepend the dest
rem test for duplicate
iff exist "%df" .and. %@IsDuplicate["%sf","%df"]==1 then
echo %f is duplicated in %df