|
This post originated from an RSS feed registered with .NET Buzz
by Peter G Provost.
|
Original Post: Monad Script: download-file
Feed Title: Peter Provost's Geek Noise
Feed URL: /error.aspx?aspxerrorpath=/Rss.aspx
Feed Description: Technology news, development articles, Microsoft .NET, and other stuff...
|
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter G Provost
Latest Posts From Peter Provost's Geek Noise
|
|
Have you ever found a something on the web and wanted to download it but there isn’t a link? If you have the URL but don’t have a link that you can right-click to save, you can use this little MSH script:
Put the following into a file called download-file.msh:
$webclient = new-object System.Net.WebClient
$start = $args[0].LastIndexOf("/") + 1
$len = $args[0].LastIndexOf("?") - $start
if( $len -lt 0 ) { $len = $args[0].Length - $start }
$target = [System.IO.Path]::Combine( $(get-location), $args[0].Substring( $start, $len ) )
$webclient.DownloadFile($args[0], $target)
Now from a MSH prompt you can type…
MSH:1> download-file "http://www.peterprovost.org/Skins/peter2/Images/Title.png"
…and it will download the header image from my blog to your current directory. You can use it with just about anything.
Enjoy!
Read: Monad Script: download-file