#!/bin/sh
# no need to install ImageMagick !!!!

analyse () { 
if [ ! -d $DIRECTORY/jpg ]
then
 mkdir $DIRECTORY/jpg
fi

cd $DIRECTORY

for i in *.xpm
do ascompose -n -s "<save format=jpeg compress=0 dst=\"./jpg/$i.jpg\"><img src=\"$i\"/></save>";
done
cd jpg
for i in ./*.xpm.jpg
do mv $i `echo $i | sed /.xpm.jpg/s/.xpm.jpg/.jpg/`
done
cd ../..
}

DIRECTORY=.
analyse

echo " "
echo "Done !"
