#!/bin/bash
HEIGHT="97%"
HEAD=\
TAIL=\<\/html\>
# Create html files, one per picture.
# Use sort to make certain of order of files for $PREV tags.
for i in $(ls *.jpg| sort -n)
do FILE=$(echo $i|sed s/.jpg/.html/)
echo $HEAD > $FILE
echo \
>>$FILE #"
echo \
>>$FILE
echo \previous \ >>$FILE
echo " " >>$FILE
export PREV=$FILE
done
# Complete and close html files.
# Reverse sort makes certain of order of files for $NEXT tags.
for i in $(ls *jpg| sort -nr)
do FILE=$(echo $i|sed s/.jpg/.html/)
echo \next \ >>$FILE #"
echo $TAIL >>$FILE
export NEXT=$FILE
done
# Special treatment for first and last files in directory, so that
# page links "wrap around".
count=1
for i in $(ls *.jpg|sort -n)
do eval PIC$count=$i
eval PREV=PIC$((count -1))
LAST=$i
LAST2=$(set |grep $PREV|grep jpg|cut -d = -f 2)
count=$((count + 1))
done
# First file
FILE=$(echo $PIC1|sed s/.jpg/.html/)
NEXT=$(echo $PIC2|sed s/.jpg/.html/)
PREV=$(echo $LAST|sed s/.jpg/.html/)
#echo FILE=$FILE; echo NEXT=$NEXT; echo PREV=$PREV
echo $HEAD>$FILE
echo \
>>$FILE
echo \
>>$FILE
echo \previous \ >>$FILE
echo " " >>$FILE
echo \next \ >>$FILE
echo $TAIL >>$FILE
# Last file
FILE=$(echo $LAST|sed s/.jpg/.html/)
NEXT=$(echo $PIC1|sed s/.jpg/.html/)
PREV=$(echo $LAST2|sed s/.jpg/.html/)
#echo FILE=$FILE; echo NEXT=$NEXT; echo PREV=$PREV
echo $HEAD>$FILE
echo \
>>$FILE
echo \
>>$FILE
echo \previous \ >>$FILE
echo " " >>$FILE
echo \next \ >>$FILE
echo $TAIL >>$FILE