How to Download All Files From a Website Directory Using Wget Windows

Published by Nyau Wai Hoe - Updated on

If you want to download all files or only certain type of files (such as only images) from a website directory or a web folder, you can use a tool called Wget in Windows to download the files automatically. In this guide, you will learn how to use Wget (a command to be executed in command prompt) to download files from a website directory in Windows 10.

Download All Files From a Website Directory

An example of such situation is when you need to download all files or only certain type of files such as images, PDF, etc, from an “Index of” web directory or a website folder. Instead of having to right-click each of them and clicking “save as”, you can download each and every file in the directory automatically using the “Wget” command in the command prompt on Windows 10. Here’s how to do it.

How to Download All Files From a Website Directory

First, you need to download the Wget tool in order to be able to use it in CMD. You can download Wget from the link below (preferably the zip version):

https://eternallybored.org/misc/wget/

Once downloaded, unzip it onto any directory you like. To make things easier later, unzip it to C:\wget.

Download Files From Web Directory Website Folder in Windows 10

Next, open an elevated Command Prompt (run as administrator).

Open CMD as admin Windows 10

To be able to run the Wget command, you need to first change the current working directory to the Wget folder. If you unzip the Wget to C:\wget earlier, in command prompt, type the following to change directory to C:\wget.

cd c:\wget

How to download a folder from a website parent directory

While you are in the directory, enter the following command to execute the automatic downloads of all files from the entered website directory.

wget -r -np -nH  https://www.example.com/dir1/dir2/dir3

How to Download All Files From a Website Directory Using Wget

Note: Replace the example website address with the actual website directory where you want to download the files from. This command will download all files from the entered website directory. The parameters are case sensitive. Below are the explanations of what each of the parameters does.

  • -r is to allow recursive download. If this is absent, the command will only download the first file on the directory.
  • -np is short for no parent. It tells the command not to ascend to the parent directory. Without this parameter, the command will ascent to and download files from the parent directories such as example.com, example.com/dir1 and example.com/dir1/dir2.
  • -nH is short for no hostname. It tells the command not to create host directories.

Download all images from website directory

The files will be downloaded onto the same directory as where the Wget.exe is. In the example above, new directories will be automatically created within the C:\wget folder and the files will be downloaded onto these directories.

Other parameters you might need

-A parameter will tells the command to download only certain type of file. For example, “-A pdf” will tell the command to only download PDF files from the website directory. If you want to download only certain type of images, for example, jpg files from a website directory, use “-A jpg”. Below is an example of including -A parameter in the Wget command.

wget -r -np -nH -A jpg https://www.example.com/dir1/dir2/dir3

-R parameter ignores certain file or type of file that you don’t want to download. For example, “-R index.html” will tell the Wget command to skip the index.html file and not download it. “-R CSS” will ignore all CSS files from the directory. Below is an example of using wget with -R parameter.

wget -r -np -nH -R index.html https://www.example.com/dir1/dir2/dir3

–cut-dirs parameter will tell the command how many directory you want to omit. For example, if you download files from https://www.example.com/dir1/dir2/dir3 without cut-dirs (and with -nH), the folder created on your PC will have the directory structure of dir1\dir2\dir3. If you want to ignore the dir1\dir2 folders, you can use the –cut-dirs command to omit the directories. Here’s an example of using wget with –cut-dirs parameter. Note that the –cut-dirs parameter has two dashes (-) in it.

wget -r -np -nH -A pdf --cut-dirs=1 https://www.example.com/dir1/dir2/dir3

Parameters are case sensitive. If you are using, for example, -A to filter download only certain type of files, if you enter -a instead, it won’t work.

To view all other available parameters you can use with Wget, in the command prompt, type the following command.

wget -help

Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of WindowsDigitals.com. With a degree in software engineering and over 12 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.

Share via
Copy link