Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!ORA.ORA.COM!jerry From: jerry@ORA.ORA.COM (Jerry Peek) Newsgroups: comp.mail.mh Subject: Re: Using { pick, scan, search } on multiple folders Message-ID: Date: 24 Mar 91 15:12:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 36 On 22 Mar 91 14:58:55 GMT, Walter Lamia wrote: > I would like to use the `search' (which uses `pick' command, right?) to find > messages in multiple folders, particularly with the -after switch, so I can > find all the messages that I filed recently, in any of my folders. This sounds like a job for a shell loop. You can type it at a shell prompt on your terminal. You don't say what you want to do with the messages you find, so let's store them in a sequence named "picked" in each folder... that way, MH will remember what messages you found in each folder. Here are examples for both the Bourne/Korn and C shells. If you have sub-folders, add "-recurse" to each "folders" command: SH/KSH CSH $ for f in `folders -fast` % foreach f (`folders -fast`) > do pick +$f -after xxx -seq picked ? pick +$f -after xxx -seq picked > done ? end Now let's get a little fancier and scan the messages you found in each folder, too -- but only if pick found some messages that match. To do that, test pick's exit status and only scan when it's zero: $ for f in `folders -fast` % foreach f (`folders -fast`) > do ? if ({ pick +$f -af xxx -seq picked }) then > if pick +$f -af xxx -seq picked ? echo ====== $f ====== > then ? scan picked > echo ====== $f ====== ? endif > scan picked ? end > fi > done Finally, to make "pick" quiet (not print "1 hit" or "No messages match specification"), just redirect its standard output and standard error: pick .... > /dev/null 2>&1 pick ... >& /dev/null --Jerry Peek, jerry@ora.com, uunet!ora!jerry