#!/bin/bash
cd ../../Modules/

echo processing: `pwd`

ls | while read CATEGORY; do
  if [ -d $CATEGORY ]; then
    echo "processing modules category:" $CATEGORY
    ls $CATEGORY | while read NAME; do  # vypise seznam modulu
      if [ -d $CATEGORY/$NAME ]; then   # zkontroluje jestli vypsane soubory jsou adresare
        echo "processing module:" $NAME
        if [ -r $CATEGORY/$NAME/PrjInfo.txt ]; then  # existuje alespon popisny soubor?
          ls $CATEGORY/$NAME/DOC/SRC/ | while read IMAGE; do
            if  [ IMAGE == *.jpg ]; then
              echo moving images to $CATEGORY/$NAME/DOC/SRC/img/              
              svn mv --parents $CATEGORY/$NAME/DOC/SRC/IMAGE $CATEGORY/$NAME/DOC/SRC/img/
            fi
          done    
        fi
        else
        echo "Nothing to done"
      fi
     done
    else
    echo "No document dir"
  fi
done

exit 0