#!/usr/bin/bash # moveme.sh # move files and directories automatically from source directory to destination directory SRC_DIR=$1 DEST_DIR=$2 if [ ! -d "$DEST_DIR" ] ; then read -p "Please provide source directory: " SRC_DIR read -p "Please provide destination directory: " $DEST_DIR fi if [ ! -d "$DEST_DIR" ] ; then echo "$DEST_DIR not found. Quitting" exit fi if [ ! -d "$SRC_DIR" ] ; then echo "$SRC_DIR not found. Quitting" exit fi txfiles=(`ls -1 $SRC_DIR`) countfiles=`ls -1 $SRC_DIR | wc -l` if (("$countfiles" < 1)) ; then # echo "No files" exit fi for i in ${txfiles[@]}; do # echo $i # echo "next" mv ${SRC_DIR}/${i} $DEST_DIR done exit # crontab -e ##m h dom mon dow command #*/5 * * * * /path/to/moveme.sh