# dirSynch

## PURPOSE

Synchronize two directory trees (or show differences between them).

## SYNOPSIS

function dirSynch( root1, root2, showOnly, flag, ignDate )

## DESCRIPTION

     Synchronize two directory trees (or show differences between them).

     If a file or directory 'name' is found in both tree1 and tree2:
      1) if 'name' is a file in both the pair is considered the same if they
         have identical size and identical datestamp (or if ignDate=1).
      2) if 'name' is a directory in both the dirs are searched recursively.
      3) if 'name' is a dir in root1 and a file in root2 (or vice-versa)
         synchronization cannot proceed (an error is thrown).
     If 'name' is found only in root1 or root2 it's a difference between them.

     The parameter flag controls how synchronization occurs:
      flag==0: neither tree1 nor tree2 has preference (newer file is kept)
      flag==1: tree2 is altered to reflect tree1 (tree1 is unchanged)
      flag==2: tree1 is altered to reflect tree2 (tree2 is unchanged)
     Run with showOnly=1 and different values of flag to see its effect.

     By default showOnly==1. If showOnly, displays a list of actions that need
     to be performed in order to synchronize the two directory trees, but does
     not actually perform the actions. It is highly recommended to run
     dirSynch first with showOnly=1 before running it with showOnly=0.

     USAGE
      dirSynch( root1, root2, [showOnly], [flag], [ignDate] )

     INPUTS
      root1    - root directory of tree1
      root2    - root directory of tree2
      showOnly - [1] show but do NOT perform actions
      flag     - [0] 0: synchronize; 1: set root2=root1; 2: set root1==root2
      ignDate  - [0] if true considers two files same even if have diff dates

     OUTPUTS
      dirSynch( 'c:\toolbox', 'c:\toolbox-old', 1 )

     EXAMPLE

     See also

     Piotr's Image&Video Toolbox      Version 2.10
     Copyright 2012 Piotr Dollar.  [pdollar-at-caltech.edu]
     Please email me if you find bugs, or have suggestions or questions!
     Licensed under the Simplified BSD License [see external/bsd.txt]