#! /bin/sh # Program to create a wrapper for all files with .gif or .jpg extensions # 2 optional command line parameters are allowed, the width in pixels, # and a prefix for the anchor names in the html file. The program # assumes that jpgnamer has already executed and the jpg files are named # in the format aaa_xxx.jpg where aaa are some alphanumeric characters # and xxx some numeric number. # procedure: # # 1) place yourself in the directory where your pictures are. # 2) type: picwrapper 70% startcount > index.html # # Picwrapper will produce a small html wrapper for each picture # in your directory. The wrapper will have the # same name as the picture but with the extension .html # The "index.html" will contain the name all the wrappers referred to # as named anchors. # The file "index.html" expects all pictures and wrappers do be placed # in the same directory. Similarly all the wrappers # contain a return link to an index.html file in the same directory. # # # The remaining task is to rearrange the photos order in index.html # (perhaps). And to reduce the 70% width to about 40% for the portrait # pictures. If required, text can be added to the wrappers or the index.html # file. Then I edit the name of the photos in index.html at leisure. ############################################################################### DATE=`date +%y%m%d` #If a parameter is given ($# >= 1), we accept it as the width if [ "$#" != "0" ]; then WIDTH=$1 else WIDTH=70% fi echo "" echo " place the title here" echo " " echo "
    " # Start processing the jpg files PASS1=1 for file in *.jpg do if [ "$file" != "*.jpg" ]; then if [ $PASS1 -eq 1 ]; then LOOP=${file%.jpg} LOOP=${LOOP#*_} LOOP=`expr $LOOP + 0` #Needed to erase leading zeroes PREFIX=${file%_*jpg}_ PASS1=0 fi PREV=`expr $LOOP - 1` NEXT=`expr $LOOP + 1` if [ $LOOP -lt 10 ]; then ASCLOOP=00$LOOP elif [ $LOOP -lt 100 ]; then ASCLOOP=0$LOOP else ASCLOOP=$LOOP fi if [ $NEXT -lt 10 ]; then ASCNEXT=00$NEXT elif [ $NEXT -lt 100 ]; then ASCNEXT=0$NEXT else ASCNEXT=$NEXT fi if [ $PREV -lt 10 ]; then ASCPREV=00$PREV elif [ $PREV -lt 100 ]; then ASCPREV=0$PREV else ASCPREV=$PREV fi # Increment the counter LOOP=`expr $LOOP + 1` if [ $PREV -gt 0 ]; then file3=$PREFIX$ASCPREV.html fi file2=$PREFIX$ASCLOOP.html file4=$PREFIX$ASCNEXT.html if [ -f $file2 ]; then # If file2 exists, move it with date stamp mv $file2 $file2.$DATE fi # Files echo "" > $file2 echo " ${file2%.html}" >> $file2 echo " " >> $file2 echo "

    " >> $file2 echo "

    Return to index

    " >> $file2 if [ $PREV -gt 0 ]; then echo "

    Previous Photo

    " >> $file2 else echo "

    Previous Photo

    " >> $file2 fi echo "

    Next Photo

    " >> $file2 echo " " >> $file2 echo "" >> $file2 echo "
  1. ${file2%.html}

  2. " fi done echo "
" echo " " echo "" exit 0