Shell Script: deleteLater.sh


This script uses an integer to create sequential directory names while moving files specified on the command line into a “deleteLater” directory.
 

#! /bin/sh

ROOTDIR="${HOME}/tmp/deleteLater/"
mkdir -p ${ROOTDIR}
NOW=`date +'%Y-%m-%d_%H-%M-%S'`

declare -i iseq
iseq=1

cmd() {
    echo $*
    $*
}

for FN in $*
do
    DELDIR="${ROOTDIR}markedForDelete_${NOW}_${iseq}/"
    mkdir -p ${DELDIR}
    cmd mv ${FN} ${DELDIR}
    iseq=iseq+1
done