How to join the files into a similar directory tree?

Finder has supported merging folders since 10.7:

If the target folder has at least one file that is newer than the corresponding file in the source folder, Finder merges the folders by keeping the newer files, and the Merge button is shown as Keep Newer:

The dialog with the Merge or Keep Newer button is shown if you copy a single folder but not if you move a folder or copy multiple folders.

Another option is to use rsync:

rsync -aE ~/dir1/rootdirectory ~/dir2/

Options:

  • -a: archive (-rlptgoD or --resursive --links --perms --times --group --owner --devices --specials)
  • -E: preserve extended attributes, resource forks, and ACLs
  • -nv: show what files would be copied (--dry-run --verbose)
  • --ignore-existing: don't replace files that are older in the destination
  • --delete: delete files from the destination that don't have corresponding files in the source