Windows 7 Forums
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

windows7 64 bit
Help Needed in Batch Script


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.


My System SpecsSystem Spec
25 Feb 2015   #2

Windows 7 Ultimate x64

hmmm im not very good with batch... but you can do this with wget.
your txt content is


then get wget and use this command
wget -i sample.txt

and for resizing, get irfanview and use batch resize function.
My System SpecsSystem Spec
26 Feb 2015   #3

Microsoft Community Contributor Award Recipient

Vista x64 / 7 X64

You can use wget -p to specify destination.

This batch file will download them into a folder called DESTINATION


@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

My System SpecsSystem Spec

26 Feb 2015   #4

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

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.

# 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 {
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 SpecsSystem Spec
26 Feb 2015   #5

windows7 64 bit

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 SpecsSystem Spec

 Help Needed in Batch Script

Thread Tools

Similar help and support threads
Thread Forum
Help Need in batch script
Hi, I have my vendor's ftp url over SSL. it's like ftps:// and i have username and password. So please help me on writing batch script t o downlod the file from my vendor repository. If this is not possible in dos script, please suggest me opensource tool. But i would love the...
General Discussion
How to run cmd.exe elevated in batch script
Hi All, I am writing a dos batch file for windows7 and it has many commands which need elevated access to run. For elevation I am using elevate.exe. I am doing like below - set Elevation=elevate -wait cmd.exe /c %Elevation% "cd /d %CD% && xcopy /E /Y ...." %Elevation% "cd /d %CD% &&...
General Discussion
batch script help
dear all any help to make batch script this the reason i want to make a batch file is to help me update the online games in 60 computers by overwriting or copying big files in one click from 1 source computer... instead of turning on all 60 computers and updating all online games, he'll just...
General Discussion
PDF file association REG or Batch Script
At work i use 2 different PDF viewing software. One is Adobe for editing and the other is Foxit for quick viewing. They have their pros and cons and so I use them interchangeably. For some work I will use Foxit for several hours at a time and only open something in Adobe on an as needed basis...
Help me with Batch script!
Hi, Can somebody assist me with a .bat file I am trying to create? This is what I have now: start /d "C:\Users\Me\Desktop\ghost" ghost.exe start /d "C:\Users\Me\Desktop" Poweroff.exe C:\Windows\System32\powercfg.exe /setactive e428f8a5-615e-488f-b7f7-1ed39450e522The first 2 lines start...

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:28.
Twitter Facebook Google+