I'm going to give you a scripting answer, there may well be a more general tool for this.
For future readers, this script describes how to copy metadata: Using ffmpeg to copy metadata from one file to another.
The following script will loop through the the files in one directory,
find corresponding files in a second directory and then combine these two files into a third output directory
dir1=FIRST DIRECTORY
dir2=SECOND DIRECTORY
output=OUTPUT DIRECTORY
for file in $(ls $dir1); do
ffmpeg -i "$dir1/$file" -i "$dir2/$file" -map 1 -c copy \
# copies all global metadata from in0.mkv to out.mkv
-map_metadata 0 \
# copies video stream metadata from in0.mkv to out.mkv
-map_metadata:s:v 0:s:v \
# copies audio stream metadata from in0.mkv to out.mkv
-map_metadata:s:a 0:s:a \
"$outdir/$file"
done
The metadata mapping command is adapted from the quoted answer.
If you want to make something reuseable you could put this in a script
with the following header (remove the assignment for dir1, dir2 and output in the script above). And then call it as script.sh dir1 dir2 outdir
#!/bin/bash
set -x errexit # exit immediately on error
dir1="$1"
dir2="$2"
output="$3"
Warning: I have no run any of these scripts.