Tolkien Gateway

User:Mithbot/Scripts

(Difference between revisions)
m (Bot: Re-linked to Nirnaeth Arnoediad)
m (Bot: Re-linked Dior Eluchíl)
(2 intermediate revisions by one user not shown)
Line 81: Line 81:
 
*''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);
*''Dior'' and ''Dior Eluchil'' to [[Dior Eluchíl]] (16 June 2010);
+
*''Dior'' and ''Dior Eluchil'' to [[Dior|Dior Eluchíl]] (16 June 2010);
 
*''Elurin'' to [[Elurín]] (16 June 2010);
 
*''Elurin'' to [[Elurín]] (16 June 2010);
 
*''Elured'' to [[Eluréd]] (16 June 2010);
 
*''Elured'' to [[Eluréd]] (16 June 2010);
Line 182: Line 182:
 
*''<nowiki>[[Category:Sandboxes| K]]</nowiki>'' to <nowiki>[[Category:Sandboxes|K]]</nowiki> (7 October 2010);
 
*''<nowiki>[[Category:Sandboxes| K]]</nowiki>'' to <nowiki>[[Category:Sandboxes|K]]</nowiki> (7 October 2010);
 
*''<nowiki>[[Category:Sandboxes]]</nowiki>'' to <nowiki>[[Category:Sandboxes|{{PAGENAME}}]]</nowiki> (7 October 2010);
 
*''<nowiki>[[Category:Sandboxes]]</nowiki>'' to <nowiki>[[Category:Sandboxes|{{PAGENAME}}]]</nowiki> (7 October 2010);
*''The Book of Lost Tales 1'' to [[The Book of Lost Tales Part 1]] (12 October 2010);
+
*''The Book of Lost Tales 1'' to [[The Book of Lost Tales Part One]] (12 October 2010);
*''The Book of Lost Tales 2'' and ''The Book of Lost Tales Party Two'' to [[The Book of Lost Tales Part 2]] (12 October 2010);
+
*''The Book of Lost Tales 2'' and ''The Book of Lost Tales Party Two'' to [[The Book of Lost Tales Part Two]] (12 October 2010);
 
*''Borondir Udalraph'' to [[Borondir]] (15 October 2010);
 
*''Borondir Udalraph'' to [[Borondir]] (15 October 2010);
 
*''<nowiki>[[Faramir|Faramir]]</nowiki>'' to [[Faramir]] (15 October 2010);
 
*''<nowiki>[[Faramir|Faramir]]</nowiki>'' to [[Faramir]] (15 October 2010);

Revision as of 14:34, 17 November 2011

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:

Changing Categories