How to compare files in different folder with windows batch script -


i trying compare files have same names in different folder. call difftool.exe bat.file , give file names exe paramater.

my script this:

@echo off  setlocal   set mydir="d:\workspace\difftool\release" set firstfolder=%mydir%\folder1 set secondfolder=%mydir%\folder2  /r "%firstfolder%" %%f in (.) (     echo %%f     /r "%secondfolder%" %%g in (%%f) (           call d:\workspace\difftool\release\difftool.exe %%f %%g     )  ) 

how can take file names string? how can pass filename second loop , call exe these file names?

output this:

enter image description here

thanks in advance.

try this:

@echo off  setlocal   set "mydir=d:\workspace\difftool\release" set "firstfolder=%mydir%\folder1" set "secondfolder=%mydir%\folder2"  /r "%firstfolder%" %%f in (*) (     /r "%secondfolder%" %%g in (*) (           call d:\workspace\difftool\release\difftool.exe "%%f" "%%g"     )  ) pause 

edit

to compare files same name+extension, use this:

@echo off  setlocal   set "mydir=d:\workspace\difftool\release" set "firstfolder=%mydir%\folder1" set "secondfolder=%mydir%\folder2"  /r "%firstfolder%" %%f in (*) (     /r "%secondfolder%" %%g in (*) (           if "%%~nxf"=="%%~nxg" call d:\workspace\difftool\release\difftool.exe "%%f" "%%g"     )  ) pause 

Comments