#filter source file list if [ -f $okl ]; then rm -f $okl fi
if [ -f $erl ]; then rm -f $erl fi
if [ ! -f $fl ]; then echo stop:1 exit 1 fi
oldIFS=$IFS IFS=$'\n' for i in $(cat $fl) do if [ -f $i ]; then echo "$i" >> $okl else echo "$i" >> $erl fi done IFS=$oldIFS
#create traget director list if [ -f $dl ]; then rm -f $dl fi
if [ ! -f $okl ]; then echo stop:2 exit 2 fi cat $okl | awk -F'/' '{$1="";NF-=1;OFS="/";print}' | sort -u > $dl
#create traget director if [ ! -f $dl ]; then echo stop:3 exit 3 fi
oldIFS=$IFS IFS=$'\n' for i in $(cat $dl) do if [ ! -d "$bdir$i" ]; then mkdir -p "$bdir$i" if [ ! $? = 0 ]; then echo "$bdir$i" >> $mdlog fi #echo $bdir$i fi done IFS=$oldIFS
#move file to traget folder if [ ! -f $okl ]; then echo stop:4 exit 4 fi
oldIFS=$IFS IFS=$'\n' for i in $(cat $okl) do if [ -f "$i" ]; then j="$bdir$(echo $i | awk -F'/' '{$1="";NF-=1;OFS="/";print}')" fi if [ -d "$j" ]; then echo s:"$i" echo d:"$j" mv -f "$i" "$j" if [ ! $? = 0 ]; then echo "$i" >> $mvlog fi fi done IFS=$oldIFS