Can Automator do this...? (And how?!)

Discussion in 'macOS' started by doowrehs, Jul 6, 2005.

  1. doowrehs macrumors regular

    Oct 14, 2004
    Hi there,

    I haven't come across much need for Automator since upgrading to Tiger, but now think I have the perfect oppportunity to test it out. The only problem is, I don't know if what I want to do is actually possible, nor exactly how I should go about it... Any help or advice would be much appreciated!

    Basically, what I'd like to do is update the source code of every page (over 80+) in my web to include a new image tag (a small banner at the bottom). I could of course do this manually i.e. open up a page, paste the line of code, save, repeat ad infinitum, but...well, I'd rather not! So, can I use Automator to do this??

    I do all my coding in Text Edit and simply store the pages in nested folders (don't use Contribute or any other web management tool). Is this the kind of task that Automator could simplify and, if so, how?!

    Any help would be much appreciated (and desperately needed!)!

  2. HexMonkey Administrator


    Staff Member

    Feb 5, 2004
    New Zealand
    I don't think Automator can do it (with built-in actions at least), but there are a few third party applications that can find and replace text in the contents of a list of files. One (written by me) is MassReplaceIt, which can be used to insert text given enough information on the context.

    For example, if you wanted to insert the new code before the same string in each file (say, "example text"), you could search for "example text" and replace it with "<new code> example text". If you decide to use any batch replacing programs, make sure you've backed up your files first, just in case.
  3. Makosuke macrumors 603

    Aug 15, 2001
    The Cool Part of CA, USA
    Assuming that there's a consistent text "hook" at the bottom of every page--some identical chunk of text to which to attach the code you're looking to ad/add (bad pun, sorry)--then any decent multi-file find and replace program will do it.

    Getting used to grep would be one way, but TextWrangler from BareBones is free and does this easily and effectively with zero learning curve. I've used it many times for exactly this sort of thing, plus it's a spectacular text editor.

    If you've got 80 pages you're updating, though, you really should be looking at at least some sort of templating engine/system, if not a full CMS system.

Share This Page