Last active
December 24, 2021 00:11
-
-
Save jorool/57714bcdc06953531749 to your computer and use it in GitHub Desktop.
Powershell script to download images from multiple urls
This file contains 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