#! /bin/csh -f

set usage = "$0 MHFOLDER"

set path = ( /usr/ucb /usr/bsd /bin )

# Tries to fix "mh" messages that have no "Date: " by 
# extracting one from the "X-VM" field.

set folder = "$1"; shift

if ( $#argv != 0 ) then
  echo "usage: ${usage}"; exit 1
endif

if ( ! ( -d ${folder} ) ) then
  echo "${folder} is not a directory"; exit 1
endif

cd ${folder}

ls | egrep '^[0-9][0-9]*$' > .all-msgs
egrep -l '^Date: ' `cat .all-msgs` > .dated-msgs
${STOLFIHOME}/bin/${PLATFORM}/bool 1-2 .all-msgs .dated-msgs > .undated-msgs

# cat .undated-msgs
${STOLFIHOME}/bin/sed-files -f ${STOLFIHOME}/lib/fake-date-in-mh-message.sed `cat .undated-msgs`

