Script used to move Experimental researches in electricity related pages to ProofreadPage format, for reference. Uses python and the pywikipedia library.

#! /usr/bin/env python
# _*_ coding: utf8 _*_
#
# Move the Experimental researches in electricity pages to ProofreadPage
# format; place soft redirects; control transclusion
#
# run with args "-log -putthrottle:xx"
#
# Copyright (C) 2006, GrafZahl (en.wikisource.org user)
#
# Licence: GPLv2
#

import wikipedia

# Handle args

args = wikipedia.handleArgs()

for arg in args:
	print u'Ignoring unrecognised argument: %s\n' % arg

# basic text tokens, etc.

numpages = 357
basename = u'Experimental_researches_in_electricity'
baseoverwrite = u'{{subst:dated soft redirect|"[[Page:Experimental_researches_in_electricity_%03d.jpg]]"}}'
basesearch = u'\\{\\{MFerie\\|%03d\\|%03d\\|%03d\\}\\}'
basereplace = u'<noinclude>{{MFerie|%03d|%03d|%03d}}</noinclude>'
movesumm = u'[bot] conversion to ProofreadPage naming conventions'
oversumm = u'[bot] dated soft redirect'
replacesumm = u'[bot] protecting navigation template from transclusion'

# Start operation

site = wikipedia.getSite()
pagenos = range(1, 51) + range(350, 358)

for n in pagenos:
	# Get all strings straight
	if n > 1:
		nminus = n - 1
	else:
		nminus = 1
	if n < numpages:
		nplus = n + 1
	else:
		nplus = numpages
	oldpage = (basename + u'/%03d') % n
	newpage = (u'Page:' + basename + u'_%03d.jpg') % n
	overwrite = baseoverwrite % n
	search = basesearch % ( nminus, n, nplus )
	replace = basereplace % ( nminus, n, nplus )
	# Step 1: Move oldpage to newpage
	print 'Moving %s to %s\n' % ( oldpage, newpage )
	page = wikipedia.Page(site, oldpage)
	try:
		page.move(newpage, movesumm)
	except wikipedia.Error:
		print 'Page move FAILED\n'
		raise
	# Step 2: Place soft redirect over oldpage
	print 'Placing soft redirect over %s\n' % oldpage
	page = wikipedia.Page(site, oldpage)
	try:
		page.put(overwrite, oversumm, None, False)
	except wikipedia.Error:
		print 'Placing soft redirect FAILED\n'
		# Go on anyway
	# Step 3: Text replacement
	print 'Replacing %s with %s in %s\n' % ( search, replace, newpage )
	page = wikipedia.Page(site, newpage)
	try:
		text = page.get()
		text = wikipedia.replaceExceptMathNowikiAndComments(text, search, replace)
		page.put(text, replacesumm, None, False)
	except wikipedia.Error:
		print 'Text replacement FAILED\n'