What is wget
?
wget
is a popular command-line tool on Linux used for downloading files from the web. It allows you to download files and folders recursively while maintaining the original directory structure. On Windows, you can use the wget.exe
version of the tool to achieve the same functionality.
Downloading and Installing wget
on Windows
- Download wget.exe: You can get the wget.exe file from reliable sources like Eternal Terminal (https://eternallybored.org/misc/wget/) or the GNU Wget website (https://www.gnu.org/software/wget/).
- Add
wget
to PATH (optional): To usewget
from any command prompt location, placewget.exe
in a folder likeC:\Windows\System32
, or add its location to yourPATH
environment variable.
Using wget
to Copy a Web Directory
Let’s say you want to copy all files from a specific site, for example: https://nas.wuibaille.fr/LeblogOSDdownload/IVANTI/
.
Here’s the command to run:
wget.exe --mirror --no-parent -P . https://nas.wuibaille.fr/LeblogOSDdownload/IVANTI/
Explanation of Options
--mirror
: This option enables mirror mode, meaningwget
will download all files and folders recursively while preserving the original directory structure.--no-parent
: Preventswget
from moving up to parent directories. This ensures that only the target directory’s contents are downloaded without including files from higher-level directories.-P .
: Specifies the download destination directory. Here,.
means the download will be saved in the current directory. You can replace.
with a specific path to store the files elsewhere.
Running this command will download all files from https://nas.wuibaille.fr/LeblogOSDdownload/IVANTI/
to your local machine, maintaining the original folder structure.
Troubleshooting with wget
in PowerShell
You might encounter an error if you simply use wget
in PowerShell, as PowerShell sometimes interprets wget
as an alias for Invoke-WebRequest
. The options you’re using (--mirror
, --no-parent
, -P
) are not compatible with Invoke-WebRequest
, which causes errors.
To avoid this confusion, explicitly use wget.exe
instead of wget
. This ensures that PowerShell runs the wget
program you downloaded, not the internal command.
Common Error: InvalidArgument
in PowerShell
If you encounter an error like:
Invoke-WebRequest : The parameter cannot be processed because the parameter name "-P" is ambiguous.
This means that PowerShell interpreted wget
as Invoke-WebRequest
. Use wget.exe
instead:
0 Comments