You could use a shell script like this:
find folder1 -name '*.jpg' | while read f; do
f2=$(find folder2 -name "${f##*/}")
[[ $f2 ]] && cp "$f" "$f2"
done
${f##*/}
removes the longest pattern matching */
from the start of $f
. [[ $f2 ]]
is equivalent to [[ -n $f2 ]]
and it tests if $f2
has non-zero length.