Find and replace across several documents?

I want to replace a string of text by a different one over hundreds of text files (html). Is there a good automated way of doing it?

Do you have an HTML editor program like HomeSite, FrontPage, etc? I know that Visual Studio 6, Visual Studio .NET and most likely FrontPage have an option for “Find and replace in all open documents” or “find and replace in entire project”.

Homesite 4.5 has a “find and replace in all open documents” too. Or maybe it was all documents in folder. Something.

If you don’t have any of those tools, perhaps find a light HTML coding tool that will do it. I’d recomment VS.NET Express (free) but it’s clunky.

Are you in a Linux environment?

sed -i “s/my old text/my new text/g” *.html

(Replace the “/” with something else if either string includes a “/”.)

If it’s Windows, you probably don’t have grep or whatever, but there are numerous equivalents available. There are probably nice easy to use GUI utilities, but here’s a little command line tool called, um, FART (find and replace tool).

So, make a new folder, put a copy of all the html files in it (in case anything goes wrong), put fart.exe in there too, open a command prompt, cd to the folder, and type in *fart .html “<what you want to change>” “<what you want to change it to>” .

I am using Adobe GoLive 5.0 (prehistoric). It does have a sitewide F&R function, but it won’t replace tags, just text.

Will check VS.NET Express. Free is always good, although I would be willing to pay a reasonable price.

Tried FART but it isn’t working. Might be because it is a long string that includes plenty of quote marks.

Tried VS Express but it is a 77MB download! Is there anything lighter?


Use the freeware text editor ConText.

Works quite well.

ConText couldn’t handle the long string either.

UltraEdit worked like a charm.

Thanks to all for the prompt replies.


oh, but I do. Pray tell. It might be useful to someone else.

Nope. Not generally.

I had posted that if you wanted, you could send me a zip file and I would affect the find/replace for you with the “sed” command above.

Oh. A very generous offer. Thank you so much.

How long was that piece of string?


Seriously, what did you find and replace, and with what?

It was about this long.

I was replacing a dummy image with a Google AdSense code. It is not that long, but it seems that the multiple lines were messing it up. The ConText window accepts only one line while UltraEdit has a multiline text field.