
export zaehler=0
export importdatum=`date +%Y.%m.%d`

cd $ABCINPUT
for i in `ls -d *`; do
	echo ""
	DOKS=`ls $i | wc -l | sed -e 's/ //g'`

	echo $i | awk -vSIL="$DOKS" '{printf("working on %-20s Doks: %3s\n",$0, SIL)}'; 

	if [ -d "$ABCOUTPUT/$i" ];
	then
		# do nothing!
		echo " " #"$ABCOUTPUT/$i existiert!"
	else
		echo "$ABCOUTPUT/$i existiert nicht, lege Verzeichnis an ..."
		mkdir $ABCOUTPUT/$i
	fi

	cd $i

	ls | grep -v Thumbs.db | while read jpg
	do
		zaehler=`expr $zaehler + 1`
		export dateiname=`echo $jpg | awk '{ k = match( $0, /[0-9_.-]/ ); j = substr( $0, 0, k - 1 ); print j; }'`
		export dummyz=$zaehler
		export jpgg=$dateiname"___"$importdatum"___"$jpg
		echo -n "$dummyz "
		#echo $jpgg
		mv "$ABCINPUT/$i/$jpg" "$ABCOUTPUT/$i/$jpgg" 2>/dev/null
	done



	cd ..
done
