Also, I am not sure you can automatically expect the output of the find command to be assigned to the file variable. I would output the find command to a temp file, and then grab the filenames one by one from the file and then put that in a do/done loop. Eg:
find ./ -type f \( -iname \*.jpg -o -iname \*.png \) > yourtempfile.tmp
for file in `cat yourtempfile.tmp`
do
echo "in loop"
echo "$file"
....
done
Here are some results I got when it ran:
in loop
./Figs_XSR900.JPG
‘.’/‘Figs_XSR900.JPG’
Renaming ./Figs_XSR900.JPG to ./356bb549-d25c-4c9b-a441-f8175f963c8c
in loop
./20240625195740_411A6199.JPG
‘.’/‘20240625195740_411A6199.JPG’
Renaming ./20240625195740_411A6199.JPG to ./3cc9ba51-1d15-4a10-b9ee-420a5666e3e2


Please, I would love to see how AI would fix this…