-
-
Save voronoipotato/01a0dd1357cfedcf17e928a8ef2b1afd to your computer and use it in GitHub Desktop.
Powershell script to download images from multiple urls
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
$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