Get all your news in one place.
100’s of premium titles.
One app.
Start reading
Tom’s Hardware
Tom’s Hardware
Technology
Ben Stockton

How to Use Wget to Download Files at Windows' Command Line

Download Files from the Windows Command Line with Wget

Most users will download files onto their PC using their web browser. There’s a problem with this method, however—it’s not particularly efficient. If you need to pause your download, or if you’ve lost your connection, you’ll probably need to start your download again from scratch. You may also be working with Python or other code at the command line and want to download directly from the command prompt. 

That’s where tools like Wget come in. This command line tool has a number of useful features, with support for recursive downloads and download resumption that allows you to download single files (or entire websites) in one go.

Wget is popular on Linux and other Unix-based operating systems, but it’s also available for Windows users. Below, we’ll explain how to install and use Wget to download any content you want online from your Windows command line.

Installing GNU Wget on Windows

Wget (in name, at least) is available on Windows 10 and 11 via the PowerShell terminal. However, this version of Wget isn’t the same as the GNU Wget tool that you’d use on a Linux PC. Instead, this version is simply an alias for a PowerShell command called Invoke-WebRequest.

Invoke-WebRequest is Wget-like in what it does, but it’s a completely different tool that’s much more difficult to use and understand. Instead, you’ll be better served by installing Wget for Windows, a compiled version of the same tool available for Linux users, using the steps below.

1. Download the Wget for Windows setup file from the Wget website. You’ll need to do this using your web browser.

2. Run the Wget for Windows installer file. Once the Wget setup file has finished downloading, run the setup file and follow the on-screen instructions to complete the installation.

(Image credit: Tom's Hardware)

3. Update the Wget.exe file (optional). The Wget installer is packaged with a fairly old version of the Wget binary. If you run into difficulties downloading files because of SSL certificate errors, you should download the latest wget.exe for your architecture from this website and save it to your Wget installation directory (typically C:\Program Files (x86)\GnuWin32\bin). This step is optional, but highly recommended.

(Image credit: Tom's Hardware)

4. Open the Start menu, search for environment variables, and click Open. Once the installation is finished, use the search tool in the Start menu to search for environment variables, then click Open. You’ll need to do this to allow you to use the ‘wget’ command from the command line without referencing its location every time you wish to run it.

(Image credit: Tom's Hardware)

5. Click Environment Variables in the System Properties window.

(Image credit: Tom's Hardware)

6. Select Path and click Edit under System or User variables.

(Image credit: Tom's Hardware)

7. Click the New button and type in the directory for the Wget for Windows binary (.exe) file. By default, this should be C:\Program Files (x86)\GnuWin32\bin.

(Image credit: Tom's Hardware)

8. Save your changes. When you’re finished, click OK in each menu and exit System Properties.

(Image credit: Tom's Hardware)

9. Open the Start menu, type cmd, and press Open. This will launch a new command prompt window.  You can also use the newer Terminal app, as long as you switch to using a command prompt shell.

(Image credit: Tom's Hardware)

10. Type wget --version and press Enter. If Wget was installed correctly, you should see the GNU Wget version returned in the command prompt window.

(Image credit: Tom's Hardware)

If you want to run Wget from a PowerShell terminal instead, you’ll need to run the file from its installation directory directly (eg. C:\Program Files (x86)\GnuWin32\bin\wget.exe).

Downloading Files with Wget

Once you’ve installed GNU Wget and you’ve configured the environment variables to be able to launch it correctly, you’ll be able to use it to start downloading files and webpages.

We’ve used an example domain and file path in our examples below. You’ll need to replace this with the correct path to the file (or files) that you want to download.

  • Type wget -h to see a full list of commands. This will give you the full list of options that you can use with Wget.
    wget -h
(Image credit: Tom's Hardware)
  • Download a single file using wget . Replace with the path to a file on an HTTP, HTTPS, or FTP server. You can also refer to a website domain name or web page directly to download that specific page (without any of its other content).
    wget example.com
(Image credit: Tom's Hardware)
  • Save with a different filename using -O. Using the -O option, you’ll be able to save the file with a different filename. For example, wget -O , where is the filename you’ve chosen.
    wget -O example.html example.com
(Image credit: Tom's Hardware)
  • Save to a different directory using -P. If you want to save to another directory than the one you’re currently in, use the -P option. For example, wget -P .
    wget -P C:\folder example.com
(Image credit: Tom's Hardware)
  • Use --continue or -c to resume files. If you want to resume a partial download, use the -c option to resume it, as long as you’re in the same directory. For example, wget -c .
    wget -c example.com
(Image credit: Tom's Hardware)
  • Download multiple files in sequence. If you want to download several files, add each URL to your Wget command. For example, wget etc.
    wget example.com tomshardware.com
(Image credit: Tom's Hardware)
  • Download multiple files using a text file with -i. Using the -i option, you can refer to a text file that contains a list of URLs to download a large number of files. Assuming that each URL is on a new line, Wget will download the content from each URL in sequence. For example, wget -i .
    wget -i urls.txt
(Image credit: Tom's Hardware)
  • Limit download speeds using --limit-rate. If you want to limit your bandwidth usage, you can cap the download speeds using the --limit-rate option. For example, wget --limit-rate=1M would limit it to 1 megabyte per second download speeds, while wget --limit-rate=10K would limit it to 10 kilobytes per second.
    wget --limit-rate=10K example.com
(Image credit: Tom's Hardware)
  • Use -w or –wait to set a pause period after each download. If you’re downloading multiple files, using -w can help to spread the requests you make and help to limit any chance that your downloads are blocked. For example, wget -w 10 for a 10 second wait. 

wget -w 10 example.com tomshardware.com

(Image credit: Tom's Hardware)
  • Set a retry limit using -t or --tries. If a download fails, wget will use the -t value to determine how many times it’ll attempt it again before it stops. The default value is 20 retries. If the file is missing, or if the connection is refused, then this value is ignored and Wget will terminate immediately.
    wget -t 5 example.com
(Image credit: Tom's Hardware)
  • Save a log using -o or -a. You can save your log data to a text file using -o (to always create a new log file) or -a (to append to an existing file). For example, wget -o .
(Image credit: Tom's Hardware)
  •  Bypass SSL errors using --no-check-certificate. If you’re having trouble downloading from a web server with an SSL certificate and you’ve already updated your Wget installation, bypass the SSL certificate check completely using --no-check-certificate to allow the download (in most cases). You should only do this for downloads from locations that you completely trust. For example, wget --no-check-certificate example.com. 

wget --no-check-certificate https://example.com

(Image credit: Tom's Hardware)

Make sure to use the wget -h or wget --help command to view the full list of options that are available to you. If you run into trouble with Wget, make sure to limit the number of retries you make and set a wait limit for each download you attempt.

Using Wget for Recursive Downloads

One of Wget’s most useful features is the ability to download recursively. Instead of only downloading a single file, it’ll instead try to download an entire directory of related files.

For instance, if you specify a web page, it’ll download the content attached to that page (such as images). Depending on the recursive depth you choose, it can also download any pages that are linked to it, as well as the content on those pages, any pages that are linked on those pages, and so on.

Theoretically, Wget can run with an infinite depth level, meaning it’ll never stop trying to go further and deeper with the content it downloads. However, from a practical point of view, you may find that most web servers will block this level of scraping, so you’ll need to tread carefully.

  • Type wget -r or wget --recursive to download recursively. By default, the depth level is five. For example, wget -r .
    wget -r tomshardware.com
(Image credit: Tom's Hardware)
  • Use -l or –level to set a custom depth level. For example, wget -r -l 10 . Use wget -r -l inf for an infinite depth level.
    wget -r -l 10 tomshardware.com
(Image credit: Tom's Hardware)
  • Use -k to convert links to local file URLs. If you’re scraping a website, Wget will automatically convert any links in HTML to point instead to the offline copy that you’ve downloaded. For example, wget -r -k .
    wget -r -k tomshardware.com
(Image credit: Tom's Hardware)
  • Use -p or --page-requisites to download all page content. If you want a website to fully download so that all of the images, CSS, and other page content is available offline, use the -p or --page-requisites options. For example, wget -r -p .
    wget -r -p tomshardware.com
(Image credit: Tom's Hardware)

For a full list of options, make sure to use the wget --h command. You should also take care to respect any website that you’re actively downloading from and do your best to limit server loads using wait, retry, and depth limits.

If you run into difficulties with downloads because of SSL certificate errors, don’t forget to update your Wget binary file (wget.exe) with the latest version.

Sign up to read this article
Read news from 100’s of titles, curated specifically for you.
Already a member? Sign in here
Related Stories
Top stories on inkl right now
One subscription that gives you access to news from hundreds of sites
Already a member? Sign in here
Our Picks
Fourteen days free
Download the app
One app. One membership.
100+ trusted global sources.