Quantcast
Channel: nature – Andy Mabbett, aka pigsonthewing
Viewing all articles
Browse latest Browse all 11

How can I automate repetitive find’n’replace operations?

$
0
0

I’m the webmaster (and a trustee) of the West Midland Bird Club, a registered charity.

Oystercatcher

Every month, I get sent a series of text files, with lists of bird sightings at each of our reserves, and some other locations. They usually comprise around thirty entries like these:

  • 6th: 1 Dunlin, 1 Oystercatcher, 2 Little Ringed Plovers, 1 Common Sandpiper, pair Shelduck, pair Greylag Geese flew over, 1 Cuckoo, pair Kingfisher, 2 Lesser Whitethroat at north end of Reserve.
  • 5th: 3 Oystercatchers, 1 Ringed Plover.

and I need to turn them into HTML markup like this:

<li class="hentry" id="D2011-05-06"><span class="entry-content"><abbr class="updated entry-title" title="2011-05-06">6th</abbr>: 1 <span class="biota bird"><b class="vernacular">Dunlin</b></span>, 1 <span class="biota bird"><b class="vernacular">Oystercatcher</b></span>, 2 <span class="biota bird"><b class="vernacular">Little Ringed Plover</b></span>, 1 <span class="biota bird"><b class="vernacular">Common Sandpiper</b></span>, pair <span class="biota bird"><b class="vernacular">Shelduck</b></span>, pair <span class="biota bird"><b class="vernacular">Greylag Geese</b></span> flew over, 1 <span class="biota bird"><b class="vernacular">Cuckoo</b></span>, pair <span class="biota bird"><b class="vernacular">Kingfisher</b></span>, 2 <span class="biota bird"><b class="vernacular">Lesser Whitethroat</b></span> at north end of Reserve.</span></li>

<li class="hentry" id="D2011-05-05"><span class="entry-content"><abbr class="updated entry-title" title="2011-05-05">5th</abbr>: 3 <span class="biota bird"><b class="vernacular">Oystercatchers</b></span>, 1 <span class="biota bird"><b class="vernacular">Ringed Plover</b></span>.</span></li>

to make pages like this one: westmidlandbirdclub.com/belvide/latest.

That involves a series of find’n’replace operations, in sequence, like:

  • Find Oystercatcher and replace with <span class="biota bird"><b class="vernacular">Oystercatcher</b></span>
  • Find Ringed Plover and replace with <span class="biota bird"><b class="vernacular">Ringed Plover</b></span>
  • Find Little <span class="biota bird"><b class="vernacular">Ringed Plover</b></span> and replace with <span class="biota bird"><b class="vernacular">Little Ringed Plover</b></span>
  • Find </b></span>s and replace with s</b></span>

…and so on. With well over 100 species in a typical series of reports, that’s a lot of faffing about. And it has to be done every month. It’s a right pain in the Wheatear.

I need to find away to automate this (under Windows XP, preferably GUI-based), working from a saved list of find’n’replace terms, and would appreciate suggestions. Is there a text editor with a facility for sequencing such operations? I could learn to write code to do it, but that’s a heavy up-front investment. Or would someone like to volunteer to help me put the code together?

Update: I’ve found a solution in ReplaceText which, though it’s sadly no longer supported and apparently doesn’t work under Windows 7, does just what I need.

Image of Oystercatcher in flight at Els Ness, Sanday, Orkney, by lukaaash.


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles



Latest Images