#!/bin/csh -f 

if ($#argv != 1) then
  echo "USAGE: mkindex.sizes.sh (dir)"
  exit 2
endif

set topdir = $argv[1]

set file = `basename $topdir`

set N = 1
foreach entry ($topdir/*)
  set file = `basename $entry`
  set md5 = `md5sum $entry | awk '{print $1}'`
  set size = `ls -l $entry | awk '{print $5}'`
  echo $file, $md5, $size

  if ("$file" == "index.php") continue
  if ("$file" == "index.mkd") continue

  if (-d $entry) then
    echo "@ $file : dir : dir$N : directory" >> $topdir/index.mkd
  endif

  if (-f $entry) then
    echo "@ $file : file : file$N : $size </td><td> $md5" >> $topdir/index.mkd
  endif

  if ($N == 1) then
    set N = 2
  else
    set N = 1
  endif
end
