Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Problem auto download / rename

$
0
0

got here a small powershell script

 

$folder = "D:\Output\"

$userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"

$web = New-Object System.Net.WebClient

$web.Headers.Add("user-agent", $userAgent)

$input = "D:\list.txt"

$delimit = " "

 

Get-Content $input |

    Foreach-Object { 

        $line = $_.split($delimit);

        $destination_file = ([io.path]::getfilename($line[1]))

        "[" + $destination_file  + "]" + "Downloading " + $line[0]

        try {

            $target = join-path $folder $destination_file

            $web.DownloadFile($line[0], $target)

        } catch {

            $_.Exception.Message + ": " + $destination_file

            add-content (join-path $folder ("downloader" + ".log")) ("[" + $destination_file + "] " + $_.Exception.Message)

            add-content (join-path $folder ("downloader" + ".retry")) ($line -join " ")

        }

    }

 

but got a problem whit the downloaded images

this sort of link is working correct

https://upload.wikimedia.org/wikipedia/commons/0/07/Boeing_727-2D3(Adv),_Alia_-_The_Royal_Jordanian_Airline_JP6534729.jpg Alia_Royal_Jordanian_Flight_600_.jpg

 

but this link not
https://en.wikipedia.org/wiki/United_Arab_Airlines_Flight_869_(1962)#/media/File:United_Arab_Airlines_de_Havilland_DH-106_Comet_4_Groves.jpg United_Arab_Airlines_Flight_869_(1962)_.jpg

i know the problem, but its not easy to change the link list....
is there an option that the powershell is edited to work whit both image links?  

thanks 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles