#!/bin/bash
# PREREQUISITE: MANUALLY CREATE THE LIST OF
# directories to be merged: /home/downloads/.drobodown.txt
while [ -s /home/downloads/.drobodown.txt ]
do
directory="$(head -n 1 /home/downloads/.drobodown.txt)"
tail -n +2 /home/downloads/.drobodown.txt > /tmp/$$.drobodown.txt
mv /tmp/$$.drobodown.txt \
/home/downloads/.drobodown.txt
mkdir -p /home/downloads/$directory || \
echo "======= ------- $directory ------- ======= FAIL directory"
if [ -d /home/drobo/downloads/$directory ]
then # merge directories
echo "======= ------- $directory ------- ======= MERGE directory"
rsync -auvzH /home/drobo/downloads/$directory /home/downloads
pushd /home/downloads/$directory || continue
fdedupe -f # generates a file .hardlinks.txt
dudir > .du.txt
popd
elif [ -f /home/drobo/downloads/$directory ]
then
echo "======= ------- $directory ------- ======= BEGIN file"
rsync -auvzH /home/drobo/downloads/$directory /home/downloads || \
echo "======= ------- $directory ------- ======= FAIL file"
else
echo "======= ------- $directory ------- ======= ONLY target"
pushd /home/downloads/$directory || continue
fdedupe -f # generates a file .hardlinks.txt
dudir > .du.txt
popd
fi
echo "======= ------- $directory ------- ======= COMPLETED"
done
syntax highlighted by Code2HTML, v. 0.9.1