Created
May 27, 2016 00:04
-
-
Save damieng/6b8041a018f78cb459939192b0938842 to your computer and use it in GitHub Desktop.
Bulk download files from a url by specifying a wildcard and numeric range
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
$sourcePattern = "http://something.com/somepath/somefile*.jpg" | |
$targetDir = "c:\downloads" | |
$count = 256 | |
New-Item -Path $targetDir -ItemType Directory -Force | |
for ($i=1; $i -le $count; $i++) { | |
$source = $sourcePattern.Replace("*", $i) | |
$parts = $source.Split('/') | |
$target = Join-Path $targetDir $parts[$parts.Length - 1] | |
echo "Downloading $source to $target" | |
(New-Object System.Net.WebClient).DownloadFileAsync($source, $target) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment