#!/bin/bash
# splitInd2HaFsubDirs V.02 (26.12.2020)     a-weinert.de
# (c) 2020 Albrecht Weinert weinert-automation.de
#
# In the directories given by parameters as relative to
# current directory and  their subdirectories the file
# index.htm will be split into pub-header.htm and
# pub-footer.htm. See the script splitInd2HaF used.

curDirStart=$PWD
echo "splitInd2HaFsubDirs start: $@"
i=1;
for dirPar in $@ ; do
 startDir="./$dirPar/"
# echo "work on ($i): $startDir" # TEST
 i=$((i + 1));
# continue; # TEST

 find $startDir -maxdepth 3 -mindepth 0 -type d | while read dir; do
# echo "$dir" # TEST
  cd $dir
# echo "I'm in $PWD and call splitInd2HaF" #TEST
  /usr/local/bin/splitInd2HaF
  cd $curDirStart
 done # over directories ./dirPar/ + subdirs
done # over parameters (dirPar)
#echo "I'm back in $PWD," #TEST
# echo "hopefully   $curDirStart" #TEST
echo "splitInd2HaFsubDirs end"
