Return-Path: welch
Received: from corvina.parc.xerox.com ([13.2.116.10]) by palain.parc.xerox.com with SMTP id <191>; Thu, 6 Oct 1994 14:59:04 -0700
Received: by corvina.parc.xerox.com id <7307>; Thu, 6 Oct 1994 14:58:49 -0700
From:	Brent Welch <welch>
To:	welch
Subject: exmh fpick
Message-Id: <94Oct6.145849pdt.7307@corvina.parc.xerox.com>
Date:	Thu, 6 Oct 1994 14:58:40 -0700


>Path: parc!decwrl!hookup!news.moneng.mei.com!howland.reston.ans.net!cs.utexas.edu!convex!news.duke.edu!zombie.ncsc.mil!gmi!msuinfo!harbinger.cc.monash.edu.au!aggedor.rmit.EDU.AU!goanna.cs.rmit.oz.au!jacana.tusc.com.au!ephor.tusc.com.au!not-for-mail
>From: jon@tusc.com.au (Jon Eaves)
>Newsgroups: comp.mail.mh
>Subject: 'ffind' is now 'fpick' and much better.
>Date: 6 Oct 1994 11:49:36 +1000
>Organization: TUSC Computer Systems Pty Ltd., Melbourne, Australia
>Lines: 126
>Message-ID: <36vl3gINNm2r@ephor.tusc.com.au>
>NNTP-Posting-Host: ephor.tusc.com.au
>Keywords: ffind, fpick, folders
>X-Newsreader: NN version 6.5.0 #6 (NOV)

Hi fellow mh users,

    As I am slack, and Bill Wohler isn't.  He has provided some much
    needed enhancements to the 'ffind' script I posted a while ago.

    Most of the enhancements are around the use of 'nested folders' 
    which I never really used (before).

    These are ; 

  	- ffind conflicts with the already existing "fast find" so I changed
      	  the name to the more intuitive "fpick."

  	- Since I have a lot of nested folders, I used "folders -recurse".

        - I have several folders that are the roots of some very large
    	  trees.  Since I'll know which tree the message is in, but perhaps
	  not the subfolder, I allow an optional folder to limit to the
	  search to that folder.

        - I use the sequence "select" for other searches and would like to
          use it in fpick, so I made the sequence a variable.  Note that
          "sequence" isn't in the usage statement because it's covered in
          pick's usage.

        - I use the folder "+hold" for other related activities and would
	  like to use it in fpick, so I made the output folder a variable.

    Without further ado, here is the updated version.  I hope this is 
    useful to a least a small number of people.

-----------------------< Jon Eaves [jon@tusc.com.au] >-------------------
    No reason to get excited, the thief he kindly spoke. There are
           many among us who think that life is but a joke.
--- TUSC Computer Systems, 666 Doncaster Rd, Doncaster, Victoria 3108 ---

	----- fpick follows -----
#!/bin/sh
#
# 'fpick script.  Mh utility
#
# usage: fpick [switches] pick-switches [+folder]
# switches are:
#   -o outfolder:	place messages in "outfolder"
#
# Jon Eaves - 05Apr1994		(jon@tusc.com.au)
# Bill Wohler - 19Sep1994	(wohler@newt.com)
#   Added arguments for flexibility.

#
# Defaults (variables that may be affected by arguments).
#
result=+fpick
sequence=fpick

#
# Initializations (internal variables that need to be set to something).
#
found="0"
folder=
pickargs=
PATH=$PATH:/usr/local/bin/mh:/usr/bin/mh
MHCONTEXT="/dev/null"			# don't change current folder
export MHCONTEXT

#
# parse arguments
#
cmd=`basename $0`			# name by which command called
while [ $# != 0 ]; do
	case "$1" in
	-v)	print=1;;
	-o)	shift; result="$1";;
	-seq*)	shift; sequence="$1";;
	+*)	folder="$1";;
	*)	pickargs="$pickargs $1";;
	esac
	shift
done

if [ "$pickargs" = "" ]; then
	echo "Usage: $cmd [-o outfolder] pick-switches [+folder]"
	exit 1
fi

#
# clear out the old fpick folder
#
rmf -nointeractive $result  2> /dev/null 1> /dev/null || exit 1

# 
# get a list of folders, not including the 'fpick' folder
#
prune="grep -x -v `echo $result | sed 's/+//'`"
for f in `folders -fast -recurse $folder | $prune`
do
  #
  # remove all from the fpick sequence in the folder
  #
  mark +$f -seq $sequence -delete all 2> /dev/null
  #
  # find all the matches
  #
  frob="`pick $pickargs +$f -sequence $sequence 2> /dev/null`"
  if [ "$frob" != "" ]
  then
    if [ "$frob" != "0" ]
    then
	found="1"
	#
	# show the number of matches in the folder
	# and add to the 'fpick' folder
	#
	echo "$f:$frob" 
	refile -src $f -link $sequence $result < /dev/null 2> /dev/null
    fi
  fi
done
#
# if there were any matches, sort them and show them
#
if [ "$found" = "1" ]
then
    sortm $result
    scan $result
fi
