#! /bin/bash

cd /data/artsdeco/queue/upload
todo=0
for f in *
do
        dossier=`echo $f | cut -f1 -d'.'`
        if [ "./$dossier" != $0 ] && [ "./$dossier" != "./*"  ]
                then
                        echo $dossier
                        mkdir -p $dossier
                        #tar -C $dossier -xvf "$f"
                        unzip "$f" -d $dossier
                        mv $f ../archives/
                        mv $dossier ../todo/
                        todo=`expr $todo + 1`
                fi
done
cd /data/artsdeco/queue/
echo "$todo archives a traiter"
if [ $todo != 0 ]
        then
                echo "Debut generation miniatures (`date`)"
                /var/www/traitementImages/scripts/generateThumbs.sh upload
                echo "Fin generation miniatures (`date`)"
                echo "Debut generation miniature de gallerie (`date`)"
                /var/www/traitementImages/scripts/generateGalleryThumbs.sh upload
                echo "Fin generation miniature de gallerie (`date`)"
                echo "Debut generation zoomify (`date`)"
                /var/www/traitementImages/scripts/generateZoomify.sh /data/artsdeco/queue/todo/
                echo "Fin generation zoomify (`date`)"
                #mv /data/artsdeco/queue/todo/* /data/artsdeco/images/
                echo "Copie de todo vers le dossier final... (`date`)"
                cp -R /data/artsdeco/queue/todo/* /data/artsdeco/images/
                echo "Fin copie (`date`)"
                echo "Suppression du contenu de todo... (`date`)"
                rm -rf /data/artsdeco/queue/todo/*
                echo "Fin suppression (`date`)"
                echo
        fi
