windows - Comparing Two Folders and its Subfolder batch file -


i have 2 folders contain same files , subfolders, conents inside each file may have changed. want write batch file search through each file , differences. what's best tool want do?

no need batch file. single fc command can want:

fc folder1\* folder2\* 

you can more specific file mask in first folder if want. example folder1\*.txt.

the command report on files exist in folder1 missing in folder2. files in folder2 ignored.

there number of options fc command. enter help fc or fc /? command prompt more information.

edit

extending solution support subfolders bit tricky. easy iterate folder hierarchy given root using /r. problem getting relative paths hierarchy can applied root.

the simplest solution use forfiles instead, since directly supports relative paths. forfiles is... s l o w :/

at point, batch file makes sense:

@echo off setlocal set "folder1=c:\path\to\folder1\root" set "folder2=d:\path\to\folder2\root" set "filemask=*"  /f "delims=" %%f in (   'echo "."^&forfiles /s /p "%folder1%" /m "%filemask%" /c "cmd /c if @isdir==true echo @relpath"' ) fc "%folder1%\%%~f\%filemask%" "%folder2%\%%~f\*" 

Comments