Advertisement
HTWingNut

Folder Comparison

May 1st, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | Software | 0 0
  1. @Echo off
  2. REM https://stackoverflow.com/questions/17599576/comparing-two-folders-and-its-subfolder-batch-file
  3. SetLocal EnableDelayedExpansion
  4.  
  5. Set "Folder1=E:\test it"
  6. Set "Folder2=E:\test it 2"
  7.  
  8. echo(>dirdiff1.log
  9. echo(>dirdiff2.log
  10.  
  11. (For /R "%Folder1%" %%x In (*.*) Do (
  12.  
  13. Set "FullPath=%%x"
  14. Set "RelPath=!FullPath:%Folder1%=!"
  15.  
  16. If Exist "%Folder2%!RelPath!" (
  17. >Nul 2>&1 FC /b "%Folder1%!RelPath!" "%Folder2%!RelPath!" && (
  18. REM Echo Dup - %%x
  19. )||(
  20. Echo Dif - %%x
  21. )
  22. ) Else (
  23. Echo New - %%x
  24. )
  25. )
  26. ) > dirdiff1.log
  27.  
  28. (For /R "%Folder2%" %%x In (*.*) Do (
  29.  
  30. Set "FullPath=%%x"
  31. Set "RelPath=!FullPath:%Folder2%=!"
  32.  
  33. If Not Exist "%Folder1%!RelPath!" (
  34. Echo New - %%x
  35. )
  36. )
  37. ) > dirdiff2.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement