Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voronoipotato/01a0dd1357cfedcf17e928a8ef2b1afd to your computer and use it in GitHub Desktop.
Save voronoipotato/01a0dd1357cfedcf17e928a8ef2b1afd to your computer and use it in GitHub Desktop.
Powershell script to download images from multiple urls
$images = 'https://foo.jpg', 'https://bar.jpg'
$targetDir = 'C:\foo\bar'
function DownloadFile([Object[]] $sourceFiles,[string]$targetDirectory) {
$wc = New-Object System.Net.WebClient
foreach ($sourceFile in $sourceFiles){
$sourceFileName = $sourceFile.SubString($sourceFile.LastIndexOf('/')+1)
$targetFileName = $targetDirectory + $sourceFileName
$wc.DownloadFile($sourceFile, $targetFileName)
Write-Host "Downloaded $sourceFile to file location $targetFileName"
}
}
DownloadFile $images $targetDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment