Skip to content

Instantly share code, notes, and snippets.

@mikecasas
Created January 4, 2016 02:49
Show Gist options
  • Save mikecasas/43fa1057554e1e6aeca9 to your computer and use it in GitHub Desktop.
Save mikecasas/43fa1057554e1e6aeca9 to your computer and use it in GitHub Desktop.
cls
$folder='http://site/wp-content/uploads'
$webClient = New-Object System.Net.WebClient
$destinationFolder='C:\p2014'
#Get the file list from the web page
$webString = $webClient.DownloadString($folder)
$lines = [Regex]::Split($webString, "<li>")
#Parse each line, looking for files and folders
foreach ($line in $lines) {
if ($line.ToUpper().Contains(".MP3")) {
$items =[Regex]::Split($line, """")
$item = $items[1]
#Write-Output $item
if($item.StartsWith("14")) {
$url=($folder + '/' + $item);
$destination=($destinationFolder + '\' + $item);
Write-Output $url
$webClient.DownloadFile($url, $destination)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment