Removing CR2 files without associated JPG file

for i in *.CR2; do echo -n "$i: checking if $(basename -s .CR2 $i).JPG exist... "; stat $(basename -s .CR2 $i).JPG >/dev/null 2>&1 && echo "yes, leaving" || (echo -n "missing, removing... " && rm $i && echo "done"); done