#!/bin/csh -f
#******************************************************************************
#FILE:				uugroup
#LANGUAGE:			csh
#SYSTEM:			UNIX
#USER-INTERFACE:	None
#DESCRIPTION
#	This is a filter to build the write commands and the delete commande for
#	a mailbox full of ftpmail-ed files.
#USAGE
#	1- Repeatedly using the 'z' command in mail, build the list of the 
#	   ftpmail-ed files and copy it in an Edit window.
#	2- Pipe this list through uugroup -w
#	3- use the generated w commands to copy the mails to files.
#	4- Pipe the w commands through uugroup -d
#	5- Use the generated d commands to clean up the mailbox.
#AUTHORS
#	<PJB> Pascal J. Bourguignon
#MODIFICATIONS
#	1995/07/?? <PJB> Creation.
#BUGS
#LEGAL
#	Copyright Pascal J. Bourguignon 1995 - 1995
#	All right reserved
#	This program may not be included in any commercial product without the 
#	author written permission. It may be used freely for any non-commercial 
#	purpose, provided that this header is always included.
#******************************************************************************

if ( ( $#argv == 0 ) || ( "$argv[1]" == "-w" ) ) then
	egrep 'ftpmail.*"\[[0-9]+ of [0-9]+\]' \
	| sed -e 's/^..\( *[0-9][0-9]*\) .* "\[\([0-9][0-9]*\) of \([0-9][0-9]*\)] .*:\(.*\)/\1:\3:\2:\4/' \
	| sort -t: +3 +1n +2n \
	| sed -e 's/\([^:]*\):\([0-9][0-9]*\):\([0-9][0-9]*\):.*\/\(.*\) uuencoded.*/w \1 \4_\2_\3/'
else if ( "$argv[1]" == "-d" ) then
	sed -e 's/w  *\([0-9][0-9]*\) .*/d \1/' \
	| sort -t\  +1n
else
	cat
	echo ''
	echo 'uugroup usage:'
	echo '	uugroup -w|-d'
endif


