#!/usr/local/bin/perl
#
# jpgindex.pl
# Revision:  0.2
# Rev Date:  20 Dec 1999
#
# Obviously you may need to adjust the path above for your system.
#
# This perl script is designed to create an index.html
# file based on the JPEG files in a given directory.
#
# It was created out of frustration while trying to figure
# out what was on all the floppies I was generating with my
# Sony Mavica camera.  Hopefully it will save you some frustration...
#
# It simply dumps the text to stdout, so to capture it,
# you will need to redirect stdout to a file, as in:
#
# jpgindex.pl > index.html
#
# note that Windows users might need "perl jpgindex.pl > index.html"
#
# If you have any comments about this script, or if you
# make an improved version, please contact Dan York at
# dyork@Lodestar2.com
#
# Copyright (C) 1998-9  Dan York, dyork@Lodestar2.com
# http://www.Lodestar2.com/software/jpgindex/
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# http://www.gnu.org/copyleft/gpl.html
# ----------------------------------------------------------
# BUGS
#
# This script looks for files ending in .JPG, which the
# Mavica uses. Ultimately it should be case-insensitive,
# so that in would index any collection of JPEGs.
#
# ----------------------------------------------------------


print <<END_OF_START;

<HTML>
<HEAD>
<TITLE>JPEG Index Page</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000099">

<h1>Index of JPEG Images</h1>

<p>
<table>
<TR>
END_OF_START

$flag=1;

while (defined($filename=glob("*.JPG"))) {

if ($flag)  {print "<TR>\n"; $flag--;} 
else {
    $flag++;
}

print "<TD>";
print "<A HREF=\"$filename\"><IMG SRC=\"$filename\" HEIGHT=240 WIDTH=320><BR>$filename</A>\n";


}

print <<END_FILE;

</table>

</body>
</html>
END_FILE

