#! /bin/csh -fe

# makes an HTML page "index.html" with pointers to all files
# "index.html" and "*-sampler.html" under the current directory.

set temp = ".temp.html"

find ./*/. \( -name 'index.html' -o -name '*sampler.html' \) -print | sort > .pages
wc -l .pages

if ( -z .pages ) then
  echo "no index pages found"
  /bin/rm .pages
  exit 1
endif

cat <<EOF > ${temp}
<html>
<head><title>`pwd`</title></head>
<body>
<h1>Images in `pwd`</h1>
<p><pre>
EOF
foreach pag ( `cat .pages` )
  echo '  <p><a href="'"${pag}"'"><tt>'"${pag}"'</tt></a></p>' >> ${temp}
end
cat <<EOF >> ${temp}
<hr>
<i>Generated on `date`</i>
</body>
</html>
EOF

mv -b -V numbered ${temp} index.html 

/bin/rm -f .pages
