Select files and merge with same filename but different extension

I have a bunch of MP4s and Wav files in a folder with the same filenames, different file extension.

I want to replace the audio in the video files with the wav.

i.e. something like this:

for i in *.MP4;   do ffmpeg -i "$  i" -i "$  {i%.*}.wav" -c:v copy -map 0:v:0 -map 1:a:0   "$  {i%.*}_merged.mp4"; done 

Is this the right way to merge all the files?