cd incoming
for d in `find . -type d`; do
if [ ! -d "../archive/$d" ]; then
mkdir -p "../archive/$d"
fi
done
for f in `find . -type f`; do
cat "$f" >> "../archive/$f"
done
This should find any file in incomingand merge it into an existing file in archive.
The important part is to be inside incoming, because otherwise we would have to cut the path prefix (which is possible, but unnecessary in this case). In the above case, the value $fusually looks like ./a/data.txt, and therefore the redirect goes to ../archive/./a/data.txt.