
#!/bin/sh
# File	: zip_move_dir.sh
# By	: MaartenDeBoer.nl, 251118
# Subject	: Script to MOVE files from a dir intop zip-file
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
LOG="${HOME}/log/${PGM}.log"

echo "`date` ${PGM} v${VER} started."|tee -a ${LOG}
echo "  in `pwd`"
sleep 1

ls -1 | while read DIR
do
  if [ -d ${DIR} ]; then
    echo "  Zipping ${DIR} into ${DIR}.zip"|tee -a ${LOG}
# Move filed from DIR in zip-file <DIR>.zip
    zip -m ${DIR}.zip ${DIR}/*
    EC=${?}
    echo "    EC=${EC}"
    if [ ${EC} -eq 0 ] || [ ${EC} -eq 12 ]; then
# EC=12 is nothing to do (due to update)
      echo "    Dir(${DIR}) wil be removed"|tee -a ${LOG}
      rmdir ${DIR}
    fi  # EC
  fi  # DIR
done  # LINE

echo "`date` ${PGM} v${VER} finished."|tee -a ${LOG}
exit 0

