#! /bin/csh -f
# eliminate all messages in $1 with duplicate message-ids
#
# Subject: MH utility to delete duplicate messages in a folder
# Date: Wed, 19 Aug 92 11:48:45 -0400
# From: Bob Munck <munck@Stars.Reston.Unisys.COM>
# 
# I debated using "$1" everywhere I have "+$1", since the user
# would then need the "+" and would be following MH conventions
# more closely.  I suppose a real convention-following utility
# would also allow defaulting by using Path from ~/.mh-profile
# to find context and getting Current-Folder from it.  

if ( ( $#argv == 0 ) || ( $1 == -help ) || ( $1 == -h ) ) then
   echo 'USAGE: prune-mail folder'
   exit 0
   endif
folder +$1
set s =  `scan +$1 -format "%4(putnumf(msg))	%{message-id}"|sort +1|uniq -d +5|sed 's/	.*$//'`
if ( "$s" != "" ) then
   rmm $s +$1
   folder +$1
   endif
