#!/usr/local/bin/vcsh

if ( $#argv >= 1 ) then
	cd $1
	echo Packing large files in `pwd`
endif

set list = ( `find . \( -name "*.pdf" -o -name "*.txt" -o -name "*.TXT" -o -name "*.RTF" -o -name "*.rtf" -o -name "*.ps"  -o -name "*.tex" -o -name "*.doc" -o -name "*.fnl" -o -name "*.midi" -o -name "*.hqx" -o -name "*.tex" \) -print` )

foreach i ( $list )
	set base = `basename $i`
	echo Test $i "[$base]"

	if ( -f $i.gz ) then
		echo File $i has been already packed
		continue
	endif

	echo Pack $i to $i.gz
	#continue

	gzip $i
	if ( $status == 0 && ! -f $i ) then
		cat << END > $i
<HTML>
<BODY>
$i was replaced by $i.gz
<hr>
Please use <strong>zcat</strong> or <strong>gunzip</strong> to view it
<hr>
<A HREF="$base.gz">$base.gz</A>
</BODY>
</HTML>
END
	endif

end

