#!/bin/sh
##
## SCRIPT: 00_GEN_tableCells4SMALLaniGifFiles_recursive.sh
##
## Started: 2010mar17
## Changed: 2010
##
## FOR TESTING:
# set -v
CELLSperROW=2
##
## Initialize the htm output filename.
##
HTMFILE="00_temp_tableCells_4SMALLaniGifFiles.htm"
if test -f "$HTMFILE"
then
rm "$HTMFILE"
fi
## Put the top of the HTML code in the html file --
## just enough code so that the page can be shown
## in a web browser with suitable formatting
## of the table cells. In particular, we need a
##
statement.
echo "
" > $HTMFILE
##
## Set the filenames list from image files in the
## "current working directory" AND ALL subdirectories,
## where this script is.
##
FILENAMES=`find . -type f -name '*' -print | grep '.gif$' | sort`
## FOR TESTING:
# echo "$FILENAMES" > "$HTMFILE"
# exit
##
## START THE LOOP on the filenames, to build the
## rows of table-cells containing a (small) aniGif image.
##
FILECNT=0
ROWCNT=0
for FILENAME in $FILENAMES
do
FILECNT=`expr $FILECNT + 1`
ROWID=""
## IF AT START of ROW, set ROWCNT and ROWID and
## write start-of-row HTML indicators.
if test `expr $FILECNT % $CELLSperROW` = 1
then
ROWCNT=`expr $ROWCNT + 1`
ROWID="row $ROWCNT"
echo "
" >> $HTMFILE
fi
FILENAMECROP=`basename "$FILENAME"`
FILENAMECROP=`echo "$FILENAMECROP" | sed 's|\_ani.gif$||' | sed 's|_transpani.gif||'`
## Write out table cell definition.
echo "
${ROWID}
${FILENAMECROP}
| " >> "$HTMFILE"
## IF AT END OF ROW, write out table-row-end indicator.
if test `expr $FILECNT % $CELLSperROW` = 0
then
echo "
" >> "$HTMFILE"
fi
done
##
## END OF FILES LOOP. Write out bottom of htm file.
##
if test `expr $FILECNT % $CELLSperROW` != 0
then
while test `expr $FILECNT % $CELLSperROW` != 0
do
echo "
| " >> "$HTMFILE"
FILECNT=`expr $FILECNT + 1`
done
echo "
" >> $HTMFILE
fi
echo "
" >> "$HTMFILE"
## Show the aniGifs-in-rows page in a text editor
## and with a web browser.
# kwrite "$HTMFILE"
gedit "$HTMFILE" &
# firefox "$HTMFILE"
seamonkey "$HTMFILE"