Bulk search-and-replace for blog entries

Last night I realized there was one more step needed to restore my 2002-2006 archive. All of my references into that archive from this blog, which started in December 2006, had to be redirected. What’s more, they had to be remapped. Old URLs like http://weblog.infoworld.com/udell/2006/12/04.html#a1571 had to become new URLs like http://jonudell.net/udell/2006-12-04-hunting-the-elusive-search-strategy.html.

Even without the remapping, it’s not obvious how to do a simple search and replace (say, from weblog.infoworld.com/udell to jonudell.net/udell) across a set of blog entries. I tried the export/edit/import route, but — at least in the case of WordPress — that doesn’t seem to be a way to update existing stuff.

So I wound up writing a script that uses the MetaWeblog API to fetch my current blog entries, find references to the old namespace, adjust them to point to the new namespace, and update the entries. It’s here for my own future reference, and for yours if you need it.

As always in these situations, I end up wondering what a civilian would do. Blog publishing systems don’t seem have bulk search-and-replace capability. They do, however, have APIs. There could be a tool or service that helps people make these kinds of changes. It’d be hard to avoid the password anti-pattern, so if this were a cloud-based service rather than a locally-installed tool you’d want to change your password after using it. But still, it should be doable.

Do such tools or services exist?

Posted in .

11 thoughts on “Bulk search-and-replace for blog entries

  1. I recently went through a similar process, moving from Movable Type to WordPress AND changing namespaces at the same time.

    It was slightly tricky, but the combination of HTTP 301 redirects and the Search and Replace [http://wordpress.org/extend/plugins/search-and-replace/] plugin did the job for me.

  2. mrblogdotorg:

    > I know of a plugin for WordPress to do
    > this.

    jason:

    > the Search and Replace
    > [http://wordpress.org/extend/plugins
    > /search-and-replace/] plugin did the job
    > for me.

    Thanks for those pointers.

    FWIW, on this iteration of my blog I decided not to use a DIY wordpress.com setup, although I’m clearly capable of doing so, but rather to use the standard kit provided at wordpress.com.

    One reason was so that I could have the same experience as people who can’t or don’t want to DIY.

    From that perspective, I’m now thinking about all the folks in that category who will never want to monkey with plugins, but who do need services that plugins typically provide, and that /could/ be provided by external tools or services through APIs.

  3. What’s the functional difference between installing a WP plugin that does some task, and setting up and running a separate script that uses the WP API to do that task? There is an access/security issue, and there are usability pros and cons to each I guess… but it seems more like a tradeoff than a sure win/lose.

  4. “What’s the functional difference between installing a WP plugin that does some task, and setting up and running a separate script that uses the WP API to do that task?”

    None really if you do it in the geeky way I did.

    But I’m imagining a service that would do the latter thing as an agent for the user.

    That service would thus provide a feature — in a way that would be independent of any blog publishing platform — that users could access and pay for a la carte.

  5. Hi, Awesome post. There is a downside to your web site within ie, could go here? Firefox however will be the industry chief and a massive element of people will omit a person’s exceptional crafting just for this trouble.

Leave a Reply to suchmaschinenoptimierungCancel reply