#!/bin/bash

ite=$1
domain=$2;
lang=$3;
in=$4;
out=$5;

ant=/cygdrive/c/work/programs/apache-ant-1.8.4/bin/ant
inDir=${in}/${domain}_${ite}/${lang}/${domain}_0.0;
echo "IN DIR";
echo ${inDir};
echo "OUT DIR";

outDir=${out};

mkdir ${outDir};
echo ${outDir};
for dir in  `ls -u ${inDir} `; do
    echo $dir;
    fulldir="$inDir/$dir";
    if [ "$(ls -A $fulldir)" ]; then
	echo "$dir not empty";
	in=${fulldir};
	echo "${fulldir} fulldir";

	mkdir ${outDir}/${lang}_${domain}_${ite};
	echo "${outDir}/${lang}_${domain}_${ite}/  DESTINATION";
	echo "COPY: ${fulldir}/*xml ${outDir}/${lang}_${domain}_${ite}/.";

	cp ${fulldir}/*xml ${outDir}/${lang}_${domain}_${ite}/.;
#	read T;
        exit 1;
    else 
	echo "$dir empty";
    fi;
done;

read T;
