PDA

View Full Version : Text edit and automator?




Flux Harmonic
Oct 11, 2005, 11:09 AM
I've come upon a situation whereby I have to edit a bunch of log files, junking the same text from each one. Ideally I'd just like to be able to run the logs through automator, and have it erase certain strings, rather than go into each one and do a series of replace-alls.

Has anyone figured out how to do this?



Bear
Oct 11, 2005, 12:15 PM
What you really need to do is write a script that used the "sed" editor to edit the files..And then you could use automator to run that.

For more details on sed: "man sed" from the terminal.

I haven't used automator, so I can't tell you all the details.

HiRez
Oct 11, 2005, 12:39 PM
You could also use TextWrangler (http://www.versiontracker.com/dyn/moreinfo/macosx/18529) (free) or BBEdit to do it. It can do search and replace on multiple files/folders, even using Regular Expressions (RegEx) if you want.

Flux Harmonic
Oct 12, 2005, 02:18 AM
It took BBedit to do it, but it did it really well. Too bad the program's like 100 bucks.

HiRez
Oct 12, 2005, 03:32 AM
It took BBedit to do it, but it did it really well. Too bad the program's like 100 bucks.That's odd, TextWrangler is basically BBEdit except for a few "pro" features for developers, but AFAIK the search & replace features are the same (I know TextWrangler can do multi-file searches and optionally use grep). What is it that BBEdit does for this that TextWrangler won't?

Flux Harmonic
Oct 12, 2005, 09:46 AM
The thing that bbedit is able to do that textwrangler can't (as far as i can tell) is set up multiple conditions for replacing text. For the most part what I'm doing is deleting lines that contain certain text strings, and there are something like 15 of them. To do this, you need to use text factories, and although textwrangler can use them, only bbedit can create them.

HexMonkey
Oct 12, 2005, 09:27 PM
Another alternative is MassReplaceIt (http://www.hexmonkey.brownhost.com), which I'm the developer of. Although it doesn't currently support regular expressions (that's likely to be added later in the year), it does support multiple search strings, searches can be saved, and it's freeware. I'm also open to suggestions, so if it lacks a feature you want, let me know and I can probably add it.

If you use it, you can delete text by entering the text in a search field, while leaving the corresponding replace field blank.