MacOS – Merge several folders, but keep only the newest file when conflicts are encountered

foldersmacosmerge

I've hit a bit of a wall with my backups. I have three backups, each is different, some contain newer files than other backups. I want to merge these three folders into one, but when a conflict arises, keep the newest version.

I've tried Path Finder with two test folders. One folder had Two sub-directories, and in each sub-directory there were two files. Each file had been modified at different times. I then worked out what the resulting merged file tree should look like, and then ran an actual test, which did not work…

enter image description here

You can see it overwrote the newer file (/One/Sub 1/File 1) with the older one (/Two/Sub 1/File 1), even though I selected "Keep Newer (modification date)" for files with the Path Finder merge. But, for some weird reason, it kept the newer file in the "Sub 2" folder.

This is obviously not right. And before I go ahead and write my own program to do this properly, I'd like to know if there are any existing, reliable programs to do this for me?

There is about 4TB of data, several million files, at stake here.

Best Answer

Just use rsync:

rsync -au .../src/ .../dest/
rsync -auiP .../src/ .../dest/ #if you need some visual output

and delete /src afterwards

with:

-a, --archive               archive mode; same as -rlptgoD  
-u, --update                skip files that are newer on the receiver  
-i, --itemize-changes       output a change-summary for all updates  
-P                          same as --partial --progress  
                            --progress show progress during transfer  
                            --partial keep partially transferred files  

Please check man rsync for -rlptgoD