#!/bin/csh -f
#
echo "This script continues the process that findobjects began.  It"
echo "will split each descript.html file into individual, per-object"
echo "files named for the object, with an extension, '.info'"
echo "It assumes the following:"
echo "  1.  You are the user who owns the JGOFS system and its files."
echo "  2.  You are running this script from the htmlbin directory."
echo "  2.  You have already run the script named 'findobjects'."
echo ""
echo "** All assumptions must be correct before proceeding **"
echo ""
echo -n "Based on the above requirements, can you continue?(y/n)"
set ans=$<
if ($ans != 'y' && $ans != 'Y') then
  exit
endif

set STARTWHERE=`pwd`
set BEGINDIR=$STARTWHERE/../objects/
cd $BEGINDIR

foreach i ( `find . -type d -print | grep "./[a-zA-Z0-9]*"`)
  echo $i
  cd $i
#
# object.list was created by script 'findobjects' and is found in each
#     subdirectory containing a descript.html file. 
#
foreach j (`cat object.list`)

nawk '\
BEGIN {ok=0;print "<h1>"}\
$0 == testvar {ok=1-ok}\
ok == 1 {print $0}\
' testvar=`echo $j` descript.html > $j.info
end

cd $BEGINDIR
end
cd $STARTWHERE
