PowerShell Example

winfred
2011-03-29
2013-05-13
  • winfred

    winfred - 2011-03-29

    Hi,

    I've written a PowerShell example that uses DotNetWikiBot.dll.

    $LocalFolderToSaveTo = "C:\DownloadLocation"
    [System.Reflection.Assembly]::LoadFile("D:\Documents\WindowsPowerShell\test\dotnetwikibot\DotNetWikiBot.dll")
    
    $EnWiki = new-object DotNetWikiBot.Site("http://en.wikipedia.org", "WikipediaUserName", "WikipediaPassword");
    $PageList = new-object DotNetWikiBot.PageList($enWiki);
    
    $PageList.FillFromCategory("Featured pictures")
    $ImageExts = ".jpg", ".png", ".jpeg"
    Foreach($Page in $PageList.pages)
    {
         if(($ImageExts -eq $Page.Title.substring($Page.Title.length - 4, 4)) -and (!($Page.Title.startswith("File talk"))) )
    
        {
         $DownloadTo = $Null
         $RenamedPage = $Page.Title.replace("File:", "")
    
        $RenamedPage = $RenamedPage.replace("`"", "") # "
         $RenamedPage = $RenamedPage.replace("`'", "")
    
        $DownloadTo = join-path $LocalFolderToSaveTo ($RenamedPage)
         $page.DownloadImage($DownloadTo)
    
        }
    }
    

    Regards,

    Winfred

    ( Article on my site )

     
  • CodeDriller

    CodeDriller - 2011-03-29

    That's cool. If someone asks me about PowerShell, I'll refer them right to your article.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks