MODE=$1
DIR=$2
shift
shift
FILES=$@


if [ ! -d $DIR ] ;  then mkdir -p $DIR; fi

for f in $FILES ; do
  TARGET=$DIR/`basename $f`
  if [ -f $TARGET ] ; then rm -f $TARGET; fi
  cp -p $f $TARGET
  chmod $MODE $TARGET
done

