#!/bin/ksh
echo "Copying files from temporary directory ${1} to FTP directory ${2}"
FILES=`ls ${1}`
echo "COPYING FROM:"
echo "    ${1}"
echo "TO"
echo "    ${2}"
echo ""
for i in $FILES
do
	echo "Testing ${1}/${i}"
	if [ -d  ${1}/${i} ]
	then
        if [ -d ${2} ]
        then
                echo "Target directory ${2} exists, no creating..."
        else
                echo "Creating target directory ${2}..."
                mkdir $2
        fi

        if [ -d ${2}/${i} ]
        then
                echo "Target directory ${2}/${i} exists, no creating..."
        else
                echo "Creating target directory ${2}/${i}..."
                mkdir ${2}/${i}
        fi

		if [ -d ${1}/${i}/WisdomNT ]
		then

        	if [ -d ${2}/${i}/WisdomNT ]
       		then
               	echo "Target directory ${2}/${i}/WisdomNT exists, no creating..."
       		else
               	echo "Creating target directory ${2}/${i}/WisdomNT..."
               	mkdir ${2}/${i}/WisdomNT
       		fi

#			echo "Copying files from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
#			cp ${1}/${i}/WisdomNT/* ${2}/${i}/WisdomNT
			echo "Linking GIF images from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
			ln -sf ${1}/${i}/WisdomNT/*.gif ${2}/${i}/WisdomNT
			ln -sf ${1}/${i}/WisdomNT/*.GIF ${2}/${i}/WisdomNT
            echo "Linking JPEG images from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
            ln -sf ${1}/${i}/WisdomNT/*.jpg ${2}/${i}/WisdomNT
            ln -sf ${1}/${i}/WisdomNT/*.JPG ${2}/${i}/WisdomNT
            echo "Linking HTML text files from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
            ln -sf ${1}/${i}/WisdomNT/?sld???.htm ${2}/${i}/WisdomNT
            echo "Linking HTML graphic files from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
            ln -sf ${1}/${i}/WisdomNT/?ld???.htm ${2}/${i}/WisdomNT
            echo "Linking HTML index file from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
            ln -sf ${1}/${i}/WisdomNT/?ndex.htm ${2}/${i}/WisdomNT
            echo "Linking PPT source files from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
		            echo "Linking PPT source files from ${1}/${i}/WisdomNT to ${2}/${i}/WisdomNT"
            ln -sf ${1}/${i}/WisdomNT/*.ppt ${2}/${i}/WisdomNT
            ln -sf ${1}/${i}/WisdomNT/*.PPT ${2}/${i}/WisdomNT
			echo "Removing non-existing null files..."
			rm ${2}/${i}/WisdomNT/?.???

 		else
			echo "Non-presentation directory, entering..."
			${3}/cp.sh ${1}/${i} ${2}/${i} ${3}
		fi
	else
		echo "File ${1}/${i}, skipping..."
	fi

done

