Text edit and automator?

Discussion in 'Mac Apps and Mac App Store' started by Flux Harmonic, Oct 11, 2005.

  1. Flux Harmonic macrumors member

    Joined:
    May 10, 2005
    Location:
    Canada
    #1
    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?
     
  2. Bear macrumors G3

    Joined:
    Jul 23, 2002
    Location:
    Sol III - Terra
    #2
    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.
     
  3. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #3
    You could also use TextWrangler (free) or BBEdit to do it. It can do search and replace on multiple files/folders, even using Regular Expressions (RegEx) if you want.
     
  4. Flux Harmonic thread starter macrumors member

    Joined:
    May 10, 2005
    Location:
    Canada
    #4
    It took BBedit to do it, but it did it really well. Too bad the program's like 100 bucks.
     
  5. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #5
    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?
     
  6. Flux Harmonic thread starter macrumors member

    Joined:
    May 10, 2005
    Location:
    Canada
    #6
    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.
     
  7. HexMonkey Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #7
    Another alternative is MassReplaceIt, 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.
     

Share This Page