Compare 2 folders and move 'not duplicates' to a new folder

There is a fleet of software that does this, for example beyond compare. It is not a free Software, but it has a free trial and for doing it once it should be fine.

You can also use diff in the terminal to search for those files like this:

diff --brief -r dir1/ dir2/

This will give you an output similar to this one:

Only in dir1/dir11/dir111: file4
Only in dir2/: file2
Only in dir1/: file3

You can then use cut and sed to get the missing files and their paths:

| cut -c 9- | sed 's/\/: /\//g' | sed 's/: /\//g'

And then you can use xargs and cp to copy the files like this:

xargs -I{} cp "{}" dir3

So the whole line would be

diff --brief -r dir1/ dir2/ | \
    cut -c 9- | sed 's/\/: /\//g' | sed 's/: /\//g' | \
    xargs -I{} cp "{}" dir3

Just make sure to replace dir1 and dir2 with directories that you want to search and dir3 with the output directory.

If you want to keep the folder structure for the copied files use ditto instead of cp like this:

diff --brief -r dir1/ dir2/ | \
    cut -c 9- | sed 's/\/: /\//g' | sed 's/: /\//g' | \
    xargs -I{} ditto "{}" dir3