Quantcast
Viewing all articles
Browse latest Browse all 21975

Download multiple files simultanously using an access database as url source?

I have an access database with a bunch of url's that points to images. What i want to do is to create a script that goes through my database and downloads all of the images simultanously.

I have tried out this script from Scripting Guy where i can pull records from access database. This screates a list with all the url's in the database, but is there a way I can tweak the script to download the images? PS-scripting is new for me so i appreciate any help you can give me. I don't ask you to solve this for me, just to help me get started :)

$adOpenStatic = 3 $adLockOptimistic = 3 $objConnection = New-Object -comobject ADODB.Connection $objRecordset = New-Object -comobject ADODB.Recordset $objConnection.Open("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\data\powershell\dbpowershell.mdb") $objRecordset.Open("Select * from TABLE", $objConnection,$adOpenStatic,$adLockOptimistic)

$url = $objRecordset.Fields.Item("url").Value
$path = "c:\test.jpg"

$webClient = new-object System.Net.WebClient; $objRecordset.MoveFirst() do {$objRecordset.Fields.Item("url").Value; $objRecordset.MoveNext()} until ($objRecordset.EOF -eq $True)

foreach ($urls in $url) {$webclient.downloadfile($url, $path)}

$objRecordset.Close() $objConnection.Close()

I am able to download "one" image when adding the following into my code:

$url = $objRecordset.Fields.Item("url").Value
$path = "c:\test.jpg"

foreach ($urls in $url) {$webclient.downloadfile($url, $path)}







Viewing all articles
Browse latest Browse all 21975

Trending Articles