Where are you piping the percentage into Zenity?
How do you think it will know when the loop loops and how many times it will loop?
Here's an example:
Code:
i=0
(while [ $((i <= 100)) '=' 1 ]
do
echo $i
sleep 1
i=$((i + 5))
done) | zenity --progress --auto-close
Basically, whenever you want to change the value of the slider, pipe the percentage value plus a newline into Zenity's stdin.
EDIT: unrelated note: You should use "*.jpg" instead of "*jpg". What if you have a file with no extension that happens to end in "jpg"?