#! /bin/csh -f # Last edited on 2002-04-30 11:27:45 by stolfi set cmd = "$0"; set cmd = "${cmd:t}" set usage = "${cmd} DATEDIR" # Creates an index for the pictures in directory DATEDIR. # Assumes that the directory contains a possibly partial # copy of a CD recorded by the Sony Mavica CD300, and possibly # other picture, in the following sub-directories: # # cd/jpeg JPEG versions of the pictures, in the CD-ROM # cd/tif TIFF versions of the pictures, in the CD-ROM # jpeg local copies of the cd/jpeg pictures # tif local copies of the cd/tif pictures # tiny local reduced copies of all pictures. # png local PNG versions of the cd/tif or cd/jpeg version # # The script assumes that pictures have names "dscNNNNN.jpg" # or "dscNNNNN.tif", and that the same number NNNNN means the # same image in different formats. # # The index is written as "index.html" in the same # directory. # if ( $#argv != 1 ) then echo "usage: ${usage}"; exit 1 endif set dir = "$1"; if ( "/${dir}" !~ /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] ) then echo "directory is not NNNN-NN-NN"; exit 1 endif cd $dir set flist = ".files" set ilist = ".images" set imgflist = ".dirs" set today = "`date`" set ofile = "index.html" /bin/rm -f ${flist} foreach subdir ( cd/jpeg cd/tif jpeg tif png tiny ) echo "listing ${subdir} ..." if ( ! ( -d ${subdir}/. ) ) then echo "warning: ${subdir} directory not found or unavailable" else find-image-files ${subdir} >> ${flist} endif end cat ${flist} \ | gawk \ ' //{ \ f = $1; gsub(/[.].*$/, "", f); gsub(/^.*[\/]/,"",f); \ if (f != "") {print f;} } \ ' \ | sort | uniq \ > ${ilist} cat > ${ofile} < HCGL UFF - Mavica CD300 - CD of ${dir}

Helena C. G. Leitão - UFF - Ceramic fragments

Mavica CD300 - CD of ${dir}

EOF set oldimg = "***" foreach img ( `cat ${ilist}` ) if ( "/${img}" !~ /dsc[0-9][0-9][0-9][0-9][0-9] ) then echo 'bad image name "'"${img}"'"' else echo "${img}" cat ${flist} \ | gawk -v img=${img} \ ' //{ \ f = $1; gsub(/[.].*$/, "", f); gsub(/^.*[\/]/,"",f); \ if (f == img) {print $1;} }' \ > ${imgflist} set tinyfile = "×" set jpegfile = "×" set tiffile = "×" set pngfile = "×" set cdjpegfile = "×" set cdtiffile = "×" set mainfile = "×" foreach imgfile ( `cat ${imgflist}` ) if ( ( "/${imgfile:h}" == "/tiny" ) && ( "${imgfile:e}" == "jpg" ) ) then set tinyfile = "${imgfile}" else if ( ( "/${imgfile:h}" == "/cd/tif" ) && ( "${imgfile:e}" == "tif" ) ) then set cdtiffile = "${imgfile}"; set mainfile = "${imgfile}" else if ( ( "/${imgfile:h}" == "/cd/jpeg" ) && ( "${imgfile:e}" == "jpg" ) ) then set cdjpegfile = "${imgfile}"; set mainfile = "${imgfile}" else if ( ( "/${imgfile:h}" == "/tif" ) && ( "${imgfile:e}" == "tif" ) ) then set tiffile = "${imgfile}"; set mainfile = "${imgfile}" else if ( ( "/${imgfile:h}" == "/png" ) && ( "${imgfile:e}" == "png" ) ) then set pngfile = "${imgfile}"; set mainfile = "${imgfile}" else if ( ( "/${imgfile:h}" == "/jpeg" ) && ( "${imgfile:e}" == "jpg" ) ) then set jpegfile = "${imgfile}"; set mainfile = "${imgfile}" else echo "unexpected image file: ${imgfile}" endif end # generate entry for image if ( "/${tinyfile}" == "/×" ) then echo "tiny version for ${img} not found" endif if ( "/${mainfile}" == "/×" ) then echo "main image file for ${img} not found" endif printf '\n' >> ${ofile} printf '\n' >> ${ofile} printf ' \n' >> ${ofile} printf ' \n' >> ${ofile} printf ' \n' >> ${ofile} printf '
\n' >> ${ofile} printf ' \n' >> ${ofile} printf '
'"${img}"'
\n' >> ${ofile} if ( "/${tiffile}" != "/×" ) then printf ' [tif]\n' >> ${ofile} endif if ( "/${pngfile}" != "/×" ) then printf ' [png]\n' >> ${ofile} endif if ( "/${jpegfile}" != "/×" ) then printf ' [jpeg]\n' >> ${ofile} endif if ( "/${cdjpegfile}" != "/×" ) then printf ' [cd/jpeg]\n' >> ${ofile} endif if ( "/${cdtiffile}" != "/×" ) then printf ' [cd/tif]\n' >> ${ofile} endif printf '
\n' >> ${ofile} endif end cat >> ${ofile} < Generated by ${cmd} on ${today}

EOF