Skip to content

Instantly share code, notes, and snippets.

@jorool
Last active December 24, 2021 00:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jorool/57714bcdc06953531749 to your computer and use it in GitHub Desktop.
Save jorool/57714bcdc06953531749 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