Linux Bash – How to change all filenames to uppercase leaving the file extension unchanged

use this simple code in bash shell. The following code will change all xxx.jpg files to XXX.jpg in any particular working directory.

for i in *.jpg; do 
ext=${i##*.}; 
name=$(basename "$i" ".$ext" | tr '[a-z]' '[A-Z]').$ext; 
if [ "$i" != "$name" ] 
then 
mv $i $name;
fi
done;