Join Forum | Login | Today's Posts | Tutorials | Windows 10 Forum | Windows 8 Forum

 Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

# Windows 7: Help Needed in Batch Script

 25 Feb 2015 #1 born2achieve windows7 64 bit 33 posts Help Needed in Batch Script Hi, I have 1000 image url in my text file(sample.txt) and i want to download the images using the url. Can anyone please share with me the sample script which can do this in single shot. Also, is there any way to reduce the size of the image into 20/20 px with png extension. Thanks My System Specs
 .
 25 Feb 2015 #2 edy1en Windows 7 Ultimate x64 7 posts hmmm im not very good with batch... but you can do this with wget. your txt content is Code: www.pic.com/pic01.jpg www.pic.com/pic02.jpg right? then get wget and use this command wget -i sample.txt and for resizing, get irfanview and use batch resize function. My System Specs
 26 Feb 2015 #3 SIW2 Vista x64 / 7 X64 9,842 posts You can use wget -p to specify destination. WGET.zip This batch file will download them into a folder called DESTINATION e.g. Code: @echo off SET TP=%~dp0 SET TP=%TP:~0,-1% cd /d "%TP%" mode con lines=40 cols=100 color 5f for /F "delims=" %%A in (MYURLS.txt) do ( wget -P DESTINATION/ %%A ) PAUSE My System Specs
 .
 26 Feb 2015 #4 Pyprohly Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan 671 posts Sydney, NSW Hi Born2achieve, As you might now know--the command prompt, or batch files for that matter, cannot download web files without the need of a third party application. If you're okay with downloading and using Wget, SIW2's batch script works... beautify. Else if not, here is a PowerShell script you may use that will get the job done. DownloadImagesFromTxtList.ps1 Code: # Duplicate items in the destination directory will be overwritten. # Edit below values $url_list = "C:\Path\to\myurls.txt"$local_output_dir = "C:\Some\destination\folder" # $WebClient = New-Object System.Net.WebClient if ( (Test-Path$local_output_dir) -eq $false ) { 'Error: The destination folder does not exist.' exit 1 } try {$fh = [IO.File]::OpenText( $url_list ) } catch [System.Management.Automation.MethodInvocationException] { 'Error: The file "' +$url_list + '" could not be found.' exit 1 } try { for (;;) { $line =$fh.ReadLine() ## Read-Host > $null # A pause statement if ($line -eq $null ) { break } if (!($line -match "^https?://.*$" )) {$line = 'https://' + $line }$line = [URI]$line 'Downloading "' +$line.OriginalString + '"...' $WebClient.DownloadFile($line.OriginalString, (Join-Path -Path $local_output_dir -ChildPath$line.Segments[-1]) ) 'Saved "' + $line.OriginalString + '" to "' + (Join-Path -Path$local_output_dir -ChildPath $line.Segments[-1]) + '"' '' } } finally {$fh.Close() } 'Done.' However, a few things must be configured prior to executing PowerShell scripts. A tutorial for running PowerShell scripts does not yet exist on this forum's tutorial index, so you're going to have to figure that one out. Also, there is a thing you should know, Born2achieve, about both the Batch and PowerShell script solutions: if a web file specified in the text file of URLs happens to not exist, the file will be downloaded anyway. So the result will not always end up being a proper functioning image. My System Specs
 26 Feb 2015 #5 born2achieve windows7 64 bit 33 posts Thank you Pyprohly for the great tip. I will try with the PowerShell and let you know. honestly i ever used PowerShell in my experience. It's new to me. but i wanted to give a try. Will postback to you once i am done. Thanks for your time and thanks everyone who tried to help me on on this post. My System Specs