Tolkien Gateway

User:Mithbot/Scripts

(Difference between revisions)
m (Added more jobs)
m (Changing Internal Links: Added more work)
Line 103: Line 103:
 
*''Morwen Eledhwen'' to [[Morwen]] (20 June 2010);
 
*''Morwen Eledhwen'' to [[Morwen]] (20 June 2010);
 
*''Húrin Thalion'' to [[Húrin]] (20 June 2010);
 
*''Húrin Thalion'' to [[Húrin]] (20 June 2010);
 +
*''Gimli Elf-friend'' to [[Gimli]] (28 June 2010);
 +
*''Legolas of Mirkwood'' and ''Legolas Greenlead'' to [[Legolas]] (1 July 2010);
 +
*''Arwen Undómiel'', ''Arwen Undomiel'' and ''Arwen Evenstar'' to [[Arwen]] (1 July 2010);
 +
*''Gandalf the Grey'' and ''Gandalf the White'' to [[Gandalf]] (1 July 2010);
 +
*''Frodo'' to [[Frodo Baggins]] (1 July 2010);
 +
*''Sam Gamgee'', ''Sam'' and ''Samwise'' to [[Samwise Gamgee]] (1 July 2010);
 +
*''Merry'' and ''Merry Brandybuck'' to [[Meriadoc Brandybuck]] (1 July 2010);
 +
*''Pippin'', ''Pippin Took'' ''Peregrin Took I'' and ''Peregrin I Took'' to [[Peregrin Took]] (1 July 2010);
 +
*''Hobbit'' to ''Hobbits'' (1 July 2010);
 +
*''Adamanta Took'' to [[Adamanta Chubb]] (2 July 2010);
 +
*''Bullroarer'' to [[Bandobras Took]] (2 July 2010);
 +
*''Bell Goodchild'' to [[Bell Gamgee]] (2 July 2010);
 +
*''Berylla Boffin'' to [[Berylla Baggins]] (2 July 2010);
 +
*''Deagol'' to [[Déagol]] (2 July 2010);
 +
*''Estella Bolger'' to [[Estella Brandybuck]] (2 July 2010);
 +
*''Elanor Gamgee'' and ''Elanor Fairbairns'' to [[Elanor Gardner]] (2 July 2010);
 +
*''Maggot'' to [[Farmer Maggot]] (2 July 2010);
 +
*''Fatty Bolger'' to [[Fredegar Bolger]] (2 July 2010);
 +
*''Broadbelt Brandybuck'' to [[Gorbadoc Brandybuck]] (2 July 2010);
 +
*''Old Took'', ''Gerontius'' and ''The Old Took'' to [[Gerontius Took]] (2 July 2010);
 +
*''Hamfast Gamgee'' and ''Gaffer'' to [[Gaffer Gamgee]] (2 July 2010);
 +
*''Hamfast Gamwich'' to [[Hamfast of Gamwich]] (2 July 2010);
 +
*''Hobson Gamgee'' and ''Roper Gamgee'' to [[Hobson]] (2 July 2010);
 +
*''Lobelia Bracegirdle'' to [[Lobelia Sackville-Baggins]] (2 July 2010);
 +
*''Linda Baggins'' to [[Linda Proudfoot]] (2 July 2010);
 +
*''Stoor'' to [[Stoors]] (2 July 2010);
 +
*''Farmer Cotton'' to [[Tolman Cotton Senior]] (2 July 2010);
 +
*''Rosie Cotton'' to [[Rose Cotton]] (2 July 2010);
 +
*''Primrose Boffin'' to [[Primrose Bracegirdle]] (2 July 2010);
 +
*''Rosamunda Bolger'' to [[Rosamunda Took]] (2 July 2010);
 +
*''Goldfather'' to [[Rorimac Brandybuck]] (2 July 2010);
 +
*''Smeagol'' to [[Sméagol]] (2 July 2010);
 +
*''Burrows'' to [[Burrows Family]] (2 July 2010);
 +
*''Brandybuck'' and ''Brandybucks'' to [[Brandybuck Family]] (2 July 2010);
 +
*''Bolger'' to [[Bolger Family]] (2 July 2010);
 +
*''Baggins'', ''Baggins family'' and ''Labingi'' to [[Baggins Family]] (2 July 2010);
 +
*''Gamgee'' to [[Gamgee Family]] (2 July 2010);
 +
*''Chubb-Baggins'' to [[Chubb-Baggins Family]] (2 July 2010);
 +
*''Took'', ''Tooks'' and ''Took family'' to [[Took Family]] (2 July 2010);
 +
*''Sackville-Bagginses'' and ''Sackville-Baggins'' to [[Sackville-Baggins Family]] (3 July 2010);
 +
*''Proudfoot'' and ''Proudfeet'' to [[Proudfoot Family]] (3 July 2010);

Revision as of 23:44, 2 July 2010

Changing Internal Links

using System;
using DotNetWikiBot;
class MyBot : Bot 
{ 
	public static void Main() 
	{ 
		Site site = new Site("http://tolkiengateway.net", "Mithbot", "PASSWORD"); 

		PageList p = new PageList(site);
 		p.FillFromLinksToPage("Bilbo");
		p.LoadEx();
		foreach (Page i in p)
			i.text = i.text.Replace("[[Bilbo]]", "[[Bilbo Baggins]]");
		p.SaveSmoothly(1, "Bot Message: changing link to [[Bilbo Baggins]]", true);
	} 

}

To avoid certain namespaces, add this before p.LoadEx();, User and Template in this example:-

		p.RemoveNamespaces(new int[] {2,10});

The above code is used to change links to a particular page in order to remove redirects. By changing "Bilbo" and "Bilbo Baggins" this script can be re-used again and again to edit internal links. So far, it has been used for changing: