DOS shellscript. How to compare and synchronise directories?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hoolaboola
    New Member
    • Oct 2010
    • 2

    DOS shellscript. How to compare and synchronise directories?

    The scripts takes two paths to folders as parameters and 1) compares them and shows the files/folders that are present in the first folder and not in the second and vice versa 2) If there are differences in the contents of the two folders then synchronises both folders' contents. In addition, if the file is present in both folders then it copies the latest file (date modified) to the folder with the older version of the file. The SYNC somehow doesn't work...
    Code:
    @echo off
    
    if "%1" == "" goto MAARAMATA
    if not exist %1 goto PUUDUB
    for /R %1 %%i in (.) do call :COMPARE "%%i"
    for /R %1 %%i in (.) do call :SYNC "%%i"
    
    goto END
    
    :MAARAMATA
    echo.
    echo No folder specified.
    
    :PUUDUB
    echo.
    echo That folder does not exist.
    
    :COMPARE
    findstr "%1" "%2" /s
    
    :SYNC
    
    XCOPY "%1" "%2" /D /I
    XCOPY "%2" "%1" /D /I
    
    goto END
    
    
    :END
Working...