Created
October 1, 2012 15:38
-
-
Save jrotello/3812564 to your computer and use it in GitHub Desktop.
Script to download the Thomson Reuters ecaldenar background images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string[]]$targetDirectories = $(throw "targetDirectories parameter is required"), | |
[string]$size = "1920x1280" | |
) | |
function getUrl ($imageNumber) { | |
$monthNumber =[System.DateTime]::Today.Month | |
$monthName = [System.Globalization.DateTimeFormatInfo]::InvariantInfo.GetAbbreviatedMonthName($monthNumber).ToLower() | |
$imageId = 4 * ($monthNumber - 1) + $imageNumber | |
$urlFormat = "http://ecalendar.thomsonreuters.com/download.asp?size={0}&mo={1}&id={2}" | |
return [String]::Format($urlFormat, $size, $monthName, $imageId) | |
} | |
function downloadWallpaper($url, $path) { | |
"Downloading $url to $path" | |
$webclient = New-Object System.Net.WebClient | |
$webclient.DownloadFile($url, "$path") | |
} | |
1..4 | % { | |
$url = getUrl $_ | |
$filename = [string]::Format("tr_{0}.jpg", $_-1) | |
$targetDirectories | % { | |
downloadWallpaper $url "$_\$filename" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment