Download Heroes Comix with the PowerShell Goodness
Are you a Heroes fan? One that's not afraid to run a powershell script? And
someone who reads my blog? If you're still reading, then today's your
lucky day! Here's a snippet I used to download the supplementary heroes
comics. Clicking hyperlinks with a mouse is for chumps! I didn't
bother to figure out how to auto-detect the number of available novels, so you
just gotta change the $number variable yerself.
$numbers = 1..31 #check out http://www.nbc.com/Heroes/novels/novels_library.shtml to see how many are online $downloadFolder = "c:\Download\HeroesNovels" ; $downloadFolder | %{ if (!(test-path $_)) { md $_ | out-null } } ; $webclient = new-object System.Net.WebClient ; $numbers = $numbers | %{ $_.ToString().PadLeft(3, "0") } | where { (!(test-path "$downloadFolder\Heroes_novel_$_.pdf")) } if ($numbers) { #FYI: same as saying ($numbers -ne $null) $i=0; $numbers | %{ $i++; write-progress "Downloading" "Heroes" -percent ($i / $numbers.count * 100) ; $webclient.DownloadFile("http://www.nbc.com/Heroes/novels/downloads/Heroes_novel_$_.pdf", "$downloadFolder\Heroes_novel_$_.pdf") ; } ; Write-Progress "Downloading" "Heroes" -completed }