User:Mithbot/Scripts: Difference between revisions

From Tolkien Gateway
m (Bot: Re-linked Dior Eluchíl)
m (Redlinks)
(One intermediate revision by one other user not shown)
Line 176: Line 176:
*''Minas Tirith of Gondor'' to [[Minas Tirith]] (3 September 2010);
*''Minas Tirith of Gondor'' to [[Minas Tirith]] (3 September 2010);
*Categorisation of uncategorised TG images and meeting templates (3 September 2010);
*Categorisation of uncategorised TG images and meeting templates (3 September 2010);
*''Image:Maedhros_sketch.jpeg'' to [[:Image:Ivanneth Maedhros.jpg]] (21 September 2010);
*''Image:Maedhros_sketch.jpeg'' to {{redlink|[[Image:Ivanneth Maedhros.jpg]]}} (21 September 2010);
*''Category:Tolkien Gateway:Users'' to [[:Category:Gatekeepers]] (7 October 2010);
*''Category:Tolkien Gateway:Users'' to [[:Category:Gatekeepers]] (7 October 2010);
*''Category:User lore-3'' to <nowiki>[[Category:User lore-3|{{PAGENAME}}]]</nowiki> (7 October 2010);
*''Category:User lore-3'' to <nowiki>[[Category:User lore-3|{{PAGENAME}}]]</nowiki> (7 October 2010);
Line 273: Line 273:
*''Category:Images from Peter Jackson's The Two Towers'' to [[:Category:Images from The Lord of the Rings: The Two Towers]] (17 November 2010);
*''Category:Images from Peter Jackson's The Two Towers'' to [[:Category:Images from The Lord of the Rings: The Two Towers]] (17 November 2010);
*''Category:Images from Peter Jackson's The Fellowship of the Ring'' to [[:Category:Images from The Lord of the Rings: The Fellowship of the Ring]] (17 November 2010);
*''Category:Images from Peter Jackson's The Fellowship of the Ring'' to [[:Category:Images from The Lord of the Rings: The Fellowship of the Ring]] (17 November 2010);
*''Category:Images of the Premiere of Peter Jackson's The Return of the King'' to [[:Category:Images from the premiere of The Lord of the Rings: The Return of the King]] (17 November 2010);
*''Category:Images of the Premiere of Peter Jackson's The Return of the King'' to {{redlink|[[Category:Images from the premiere of The Lord of the Rings: The Return of the King]]}} (17 November 2010);
*''Category:Images from Peter Jackson's The Lord of the Rings'' to [[:Category:Images from The Lord of the Rings: The Motion Picture Trilogy]] (17 November 2010)'
*''Category:Images from Peter Jackson's The Lord of the Rings'' to {{Redlink|[[:Category:Images from The Lord of the Rings: The Motion Picture Trilogy]]}} (17 November 2010)'
*''Category:Images from Rankin/Bass' The Return of the King'' to [[:Category:Images from The Return of the King (1980 film)]] (18 November 2010);
*''Category:Images from Rankin/Bass' The Return of the King'' to [[:Category:Images from The Return of the King (1980 film)]] (18 November 2010);
*''Category:Images from Rankin/Bass' The Hobbit'' to [[:Category:Images from The Hobbit (1977 film)]] (18 November 2010);
*''Category:Images from Rankin/Bass' The Hobbit'' to [[:Category:Images from The Hobbit (1977 film)]] (18 November 2010);
*''Category:Images from Ralph Bakshi's The Lord of the Rings'' to [[:Category:Images from The Lord of the Rings (1978 film)]] (18 November 2010);
*''Category:Images from Ralph Bakshi's The Lord of the Rings'' to [[:Category:Images from The Lord of the Rings (1978 film)]] (18 November 2010);
*Added uncategorised book images to [[:Category:Images of books]] (15 November 2010);
*Added uncategorised book images to [[:Category:Images of books]] (15 November 2010);

Revision as of 12:28, 20 August 2014

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

Category:Images from The Lord of the Rings: The Motion Picture Trilogy[former link] (17 November 2010)'