Although I do often write short programs for text munging, I typically resort to that only if the problem requires more than just large-scale text editing or if I expect to be repeating the process several times. And even then, I usually start out by playing around in BBEdit to see what searches, replacements, and rearrangements need to be done. It’s a convenient environment for getting immediate feedback on each transformation step.
I did this just yesterday setting up the tags for the new site layout. BBEdit is the kind of tool that makes difficult things easier and impossible things possible.