As Stephan pointed out, this code is for the linux command line, not the windows cmd. so it would need git bash terminal or wsl to run.
The question is about cmd (the Windows command line). Running
Unix/Linux code would require installing additional tools, which
explicitly is not wanted by the asker.
This code will copy all unmatched files from folder1 and folder2 into folder 3.
This first line gets all the directories and files of folder1 &
folder2 and lists them in a file.
(ls -d folder1/* && ls -d folder2/*) > dir.txt
This line gets the unmatched files that do not exist in both directories and lists them in a file.
diff -r <(ls folder1) <(ls folder2) | sed 's/^< //' | sed 's/^> //' > unique.txt
This line greps the full file paths from the directory file that exist in the unmatched files and lists them.
grep -wFf unique.txt dir.txt | sed 's/^< //' | sed 's/^> //' > tocopy.txt
Now that we have a list of all the filepaths we can just copy them to folder3.
cp -r $(cat tocopy.txt) folder3