[Pywikipedia-l] How to mass rename articles?
Merlijn van Deen
valhallasw at arctus.nl
Tue Aug 10 08:40:14 UTC 2010
On 10 August 2010 09:24, Bináris <wikiposta at gmail.com> wrote:
> All the "0" chars in titles mean "any digit". As far as I see, move.py does
> not handle regexps in the way replace.py does, although I would just need
> this feature.
>
> How would you solve this problem?
>
>
Use the framework instead of relying ready-to-use bots. Use
the PrefixingPageGenerator combined with the RegexFilterPageGenerator (from
pagegenerators.py) to yield the correct pages to move. Something like:
>>> gen = RegexFilterPageGenerator(PrefixingPageGenerator("kkStB"), r"kkStB
[0-9][0-9]?[0-9]?")
>>> for page in gen:
... print page
...
[[KkStB 1]]
[[KkStB 10]]
[[KkStB 105]]
[[KkStB 106]]
[[KkStB 108]]
[[KkStB 110]]
[[KkStB 110.500]]
[[KkStB 129]]
[[KkStB 14]]
[[KkStB 151]]
[[KkStB 166]]
[[KkStB 17]]
[[KkStB 179]]
[[KkStB 180]]
[[KkStB 180.500]]
[[KkStB 205]]
[[KkStB 206]]
[[KkStB 207]]
[[KkStB 210]]
[[KkStB 211]]
[[KkStB 229]]
[[KkStB 231]]
[[KkStB 27]]
[[KkStB 270]]
[[KkStB 306]]
[[KkStB 31.01–11]]
[[KkStB 310]]
[[KkStB 310.300]]
[[KkStB 32]]
[[KkStB 329]]
[[KkStB 378]]
[[KkStB 393]]
[[KkStB 4]]
[[KkStB 406]]
[[KkStB 46]]
[[KkStB 5]]
[[KkStB 506]]
[[KkStB 571]]
[[KkStB 6]]
[[KkStB 60]]
[[KkStB 7]]
[[KkStB 76 sorozatú szerkocsi]]
of course, adapt the regexp to create a slightly better filter. These pages
can then be moved using the move(newtitle) method of the page object.
Best regards,
Merlijn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wikimedia.org/pipermail/pywikipedia-l/attachments/20100810/63e9292c/attachment.htm
More information about the Pywikipedia-l
mailing list