Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!apple.com!chewy From: chewy@apple.com (Paul Snively) Newsgroups: comp.sys.mac.programmer Subject: Re: MPW Search & Replace Message-ID: <9786@goofy.Apple.COM> Date: 15 Aug 90 22:58:12 GMT References: <23683@dartvax.Dartmouth.EDU> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 44 In article <23683@dartvax.Dartmouth.EDU> isle@eleazar.dartmouth.edu (Ken Hancock) writes: > As our projects at work have steadily grown larger and larger, we > finally switched to MPW a while back. Alas, I've been spoiled > by the THINK C environement and one of the things that MPW seems > to lack is a decent multi-file search and replace. Does anyone > on the net have such a beast? What's wrong with the Replace command? Here is a useful (sometimes) variation on the theme: For File in 'Files -f -o -r -s ' Target "{File}" Find Replace -c /RegExp/ Close -y "{Target}" End (Use your imagination to turn the above single-quotes into backquotes.) This will recursively enumerate everything in the DirectorySpec, Target it, Replace the RegExp with the string, and save the changes. You can futz with the "Files" command in the above fragment to achieve other results, e.g. 'Files -t TEXT' will enumerate only text files, etc. For a lot of applications, a variation using the Search command might be better. Search will deal only with text files anyway, and returns a list of File... ; Line... commands which you might redirect to a temorary file and then iterate across and Evaulate, etc. to get at the match and futz with. Hope this helps! __________________________________________________________________________ Paul Snively Macintosh Developer Technical Support Apple Computer, Inc. chewy@apple.com Just because I work for Apple Computer, Inc. doesn't mean that I believe what they believe, or vice-versa. __________________________________________________________________________