Tuesday, March 27, 2007

HTTP Downloads (more batch goodness)

After downloading so many GNU/Linux distro CDs, you cross a point when you just fall in love with your BitTorrent client and everything it is. I enjoy little more than being able to just ignore whatever files I'm trying to download and then come back a week later, "Oh, look at that, finished." That's one of the great things about P2P downloading.

Unfortunately not everyone has caught up with the times. Every once in a while you find the website that has a great file you just have to have, but they only offer plain old vanilla HTTP downloads. (Those are the type that you click on the link and your web browser asks you "Where do you want to save this?")

That's great and all, unless you won't be there when it's finished. Then you're crossed with the dilemma of downloading the file and leaving your computer on over-night or all weekend or however long you'll be gone. I'm one of those people that greatly frown upon the wastefulness of leaving your computer on all the time, and thus always wanted some kind of solution for it. Time to break out the batch script.

Step 1. Collect the needed tools.
This is a pretty simple script, only using two commands: shutdown and wget. shutdown is a system .exe and should already be in C:\Windows\System32\shutdown.exe
wget is where it gets a little bit harder. It was originally a *nix tool which has been ported over to Windows. wget website [1] Download the windows binary and add it to your path. (The simplest, yet not cleanest, is to just copy-paste wget.exe into C:\Windows\System32\, I'll get into doing this better later)

Step 2. Write the script.
Pretty simple script. Just find the URL for the file you want to save and open up notepad or whatever text editor you want to use.
wget yourURLhere
shutdown -s

Then save it as "downloader.bat" In notepad you'll need to use the quotes so it doesn't save it as downloader.bat.txt. And there you have it.

Step 3. Run
Once you've saved it, save-close out of everything like you're about to shutdown, double-click the downloader.bat script, and walk away. It will download until it's done and then shutdown your computer. Pretty neat!


[1] http://www.gnu.org/software/wget/