#!/bin/sh

if [ "$#" -ne 1 ] || [ "$1" -le 0 ]
then
	echo "USAGE: $0 Numfiles" 2>&1
	exit 1
fi

if ! mkdir "test$1"
then
	echo "Could not create test directory" 2>&1
	exit 1
fi

mkdir "test$1/src"
mkdir "test$1/dst"
mkdir "test$1/bak"
mkdir "test$1/log"

mkdir files
dd if=/dev/zero of=files/0000_0000.jpg_original bs=1024 count=1
dd if=/dev/zero of=files/0000_0000.jpg bs=512 count=1

for a in `seq -w 1 "$1"`
do
	cp -p files/0000_0000.jpg_original "test$1/dst/${a}.jpg"
	cp -p files/0000_0000.jpg          "test$1/src/${a}.jpg"
	cp -p files/0000_0000.jpg_original "test$1/src/${a}.jpg_original"
done

rsync -avvHAXSkK --backup --backup-dir="$PWD/test$1/bak"  "$PWD/test$1/src/." "$PWD/test$1/dst/."  >> "test$1/log/out" 2>&1
