#!/bin/bash

for file in `ls -1`
do
    prefix=`echo $file | cut -f1 -d"."`
    orig=`ls -l $file`
    echo "--- Processing $file "
    convert $file $prefix.png
    convert $prefix.png -resize 400x400 $prefix.new.png
    optipng -o7 $prefix.new.png
    rm -f $prefix.png
    mv $prefix.new.png $file
    echo "$orig"
    ls -l $file
done
