Loop through directory convert jpg to png

Hi guys. I will be frequently needing to convert .jpg files to 183x183 .png thumbnails. I can't quite seem to wrap my head around how to make a for loop to do this.

With the help of my friend (who may have mislead me, I'm quite confused) I've got this.

This is bash

the command is: pngify <source directory> <destination directoy>

for picture in $(?) ====> I'm quite sure this part is wrong...
do
        echo ${picture%.*}>picturewithoutext     =====|This part is to remove the 
        picnoext=`cat picturewithoutext`               =====|extension so I can name 
        rm picturewithoutext                   ======== ===|the new file the same thing with a .png

        convert -size 183x183 $1/$picture $2/$picnoext.png  
done

Yes, I am very new to shell scripting ^_^;;

You don't need temporary file for removing file's extension. Try this:

#!/bin/sh
for picture in `ls $1`
do
        picnoext=${picture%.*}
        echo "convert -size 183x183 $1/$picture $2/$picnoext.png"
done

why the use of ls ? use shell expansion

for picture in $1/*

Did you try it? :smiley:
With `ls $1`:

[root@linux sh]# ./a.sh /root/sh /root/jj
convert -size 183x183 /root/sh/a.sh /root/jj/a.png
convert -size 183x183 /root/sh/file.jpg /root/jj/file.png

and with $1/*:

[root@linux sh]# ./a.sh /root/sh /root/jj
convert -size 183x183 /root/sh//root/sh/a.sh /root/jj//root/sh/a.png
convert -size 183x183 /root/sh//root/sh/file.jpg /root/jj//root/sh/file.png