Tolkien Gateway

User:Mithbot/Scripts

(Difference between revisions)
m (Changing Internal Links: Added more work)
m (Changing Internal Links: Added some more; corrected some early errors in records)
Line 78: Line 78:
 
*''Anarion'' and ''Anárion son of Elendil'' to [[Anárion]] (16 June 2010);
 
*''Anarion'' and ''Anárion son of Elendil'' to [[Anárion]] (16 June 2010);
 
*''Lord of Andúnië'' to [[Lords of Andúnië]] (16 June 2010);
 
*''Lord of Andúnië'' to [[Lords of Andúnië]] (16 June 2010);
*''Andune'' to [[Andúnië]] (16 June 2010);
+
*''Andunie'' to [[Andúnië]] (16 June 2010);
 
*''Anduril'' to [[Andúril]] (16 June 2010);
 
*''Anduril'' to [[Andúril]] (16 June 2010);
 
*''Eomer'' and ''Éomer Éadig'' to [[Éomer]] (16 June 2010);
 
*''Eomer'' and ''Éomer Éadig'' to [[Éomer]] (16 June 2010);
Line 99: Line 99:
 
*''Malach Aradan'' to [[Malach]] (18 June 2010);
 
*''Malach Aradan'' to [[Malach]] (18 June 2010);
 
*''Dunlending language'' to [[Dunlendish]] (20 June 2010);
 
*''Dunlending language'' to [[Dunlendish]] (20 June 2010);
*''Haleth the Hunter' to [[Haleth]] (20 June 2010);
+
*''Haleth the Hunter'' to [[Haleth]] (20 June 2010);
 
*''Túrin Turambar'', ''Turin'' and ''Turindo'' to [[Túrin]] (20 June 2010);
 
*''Túrin Turambar'', ''Turin'' and ''Turindo'' to [[Túrin]] (20 June 2010);
 
*''Morwen Eledhwen'' to [[Morwen]] (20 June 2010);
 
*''Morwen Eledhwen'' to [[Morwen]] (20 June 2010);
Line 144: Line 144:
 
*''Sackville-Bagginses'' and ''Sackville-Baggins'' to [[Sackville-Baggins Family]] (3 July 2010);
 
*''Sackville-Bagginses'' and ''Sackville-Baggins'' to [[Sackville-Baggins Family]] (3 July 2010);
 
*''Proudfoot'' and ''Proudfeet'' to [[Proudfoot Family]] (3 July 2010);
 
*''Proudfoot'' and ''Proudfeet'' to [[Proudfoot Family]] (3 July 2010);
 +
*''Ainu'' to [[Ainur]] (6 July 2010);
 +
*''Aiwendil'' and ''Radagast the Brown'' to [[Radagast]] (6 July 2010);
 +
*''Aldarion'' to [[Tar-Aldarion]] (6 July 2010);
 +
*''Aldarion and Erendis'' to [[Aldarion and Erendis: The Mariner's Wife]] (6 July 2010);
 +
*''Amandil of Númenor'' and ''Ar-Aphanuzir'' to [[Tar-Amandil]] (6 July 2010);
 +
*''Mother-name'', ''Mother-names'' and ''Mn'' to [[Amilessë]] (6 July 2010);
 +
*''Amon Hen journal'' to [[Amon Hen (journal)]] (6 July 2010);
 +
*''Andreas Moehn'' to [[Andreas Möhn]] (7 July 2010);
 +
*''Angaráto'' to [[Angaráto]] (7 July 2010);
 +
*''Anglo-Saxon'' to [[Old English]] (7 July 2010);
 +
*''Angrenost'' to [[Isengard]] (7 July 2010);
 +
*''Anke Eissman'' to [[Anke Eißmann]] (7 July 2010);

Revision as of 00:01, 7 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: