#! /bin/csh -f
# Last edited on 2001-11-30 15:03:40 by stolfi

set usage = "$0 DIRS > CAPTIONSFILE"

# Finds and concatenates all image caption ("p.comments") files in the 
# given directories.  Each caption is indented with "+ " and preceded by a line 
# with the name of the image set (parent directory).

set tmp = "/tmp/$$.comments"

find $* -name 'p.comments' -print \
  | sed -e 's:^[.]/::g' -e 's:/[.]/:/:g' \
  > ${tmp}

foreach f ( `cat ${tmp}` )
  set img = ${f:h}
  echo "$img"
  cat $f \
    | sed -e 's/^/+ /'
  echo " "
end

/bin/rm -f ${tmp}