#!/bin/bash
# reza
# script to generate index using last image in each dir and
#  local root images

cd /c/wwwroot/food/

ls -F | grep /$ | sed "s/\/$//" | awk '{printf("ls %s | egrep -i \"jpg|gif\" | tail -1 | sed \"s/^/%s /\"\n",$1,$1)}' > tfd1
chmod 755 tfd1
echo "<html><pre><center>" > index.html
./tfd1 | awk '{n=$1;gsub(/_/," ",n);printf("%s\n<a href=\"%s\"><img src=\"%s/%s\" border=0></a>\n\n\n",n,$1,$1,$2)}' >> index.html
ls | egrep -i "jpg|gif" | awk '{split($0,a,".");gsub(/_/," ",a[1]);printf("%s\n<img src=\"%s\">\n\n\n",a[1],$0)}' >> index.html
echo "<a href=\"/\">Home</a>" >> index.html
echo >> index.html
echo >> index.html
echo "<font size=-1>Generated using <a href="$0">$0</a> (c) 2005" >> index.html
date >> index.html
echo "</font></html>" >> index.html
rm -f tfd1
