How to download a whole folder using wget on Windows or Linux and cmd magic
We sometimes need to download some full ftp folder, especially when teachers / lecturers share some materials (or presentations) and won't think of putting it in one archive. If we try just using command:
wget http://some.ftp.com/folder/and/folder2
we would get index.html file. We should do that this way:
wget -r -np -nH –cut-dirs=3 -R index.html http://some.ftp.com/folder/and/folder2
We will get all the files from folder2. I found this solution here. It seems that there's more nerd friendly stuff.
But to explain it to humans: you use wget from command line. On Windows it would be cmd.exe. You may just search for cmd.exe and I recommend to make a shortcut for it, which we will use for some nice trick.
Normally wget installs to "C:\Program Files\GnuWin32\" and application executable is inside folder "bin". So, to use it in command line, we would need to type or copy full path every time we use it, but here comes doskey:
DOSKEY wget="C:\Program Files\GnuWin32\bin\wget.exe" $*
This command makes "wget" point to our wget.exe binary. But after exiting cmd, it will 'forget' what we set with doskey. To avoid this, we create a *.cmd file using notepad or whatever text editor we like, paste above code there and save as "filename.cmd". It should look like this:
@echo off
DOSKEY wget="C:\Program Files\GnuWin32\bin\wget.exe" $*
Thanks to first line we won't see any notifications starting terminal with this file. We create then shortcut to cmd.exe, and then edit it to make it point to "C:\Windows\System32\cmd.exe /K C:\path\to\your\file.cmd". Now when we start cmd using our link "wget" runs wget. We may also add an alias for downloading full directory:
DOSKEY wgetdir="C:\Program Files\GnuWin32\bin\wget.exe" -r -np -nH ‐‐cut-dirs=3 -R index.html $*
Now command for downloading a whole ftp directory and its subdirectories would be:
wgetdir http://some.ftp.com/and/its/folders/
I hope you enjoy being nerds with me.
Here's where I found the doskey solution.