Things get really nerdy when you create your own, new DOS command by using batch files. Warning: today’s blog post is really nerdy!
I wanted a single DOS command to create ZIP files. Sure, I could have downloaded WinZIP or some other ZIP utility. But I enjoy doing things myself — and then sharing the solutions with others.
The solution I came up with for creating ZIP files, or Compressed Folders, at the command prompt is the MKZIP
command. MKZIP
builds empty ZIP files. Here’s how:
First, I started with an empty ZIP file. I used Windows to create a Compressed Folder. I noticed that the new Compressed Folder, which is empty, occupies only 22 bytes of computer storage. That’s incredibly tiny, but also convenient: I can easily recreate those 22 bytes to make my own ZIP files. The problem is how?
I used the DEBUG
utility to look at the contents of the empty ZIP file.
DEBUG
is an old, old DOS program. It’s actually an Assembler, used to create machine language code. I’ve written quite a few programs using nothing more than DEBUG
and a knowledge of 8088 instruction code. I’ve also used DEBUG
to debug my code.
There are better tools than DEBUG
, of course, but for creating tine programs or looking at the guts of a file, DEBUG
is perfect.
Here’s what I saw looking at the contents of the empty ZIP file in DEBUG
:
Yes, it’s technical! The file is 22 bytes long, which translates into 0x16
. So the DEBUG
command to list the ZIP file’s contents is:
d100 l16
That’s D
, for Display, at memory location 100
for L
, length, 16
bytes. The values are in hexadecimal. But the contents of the file is shown: Basically you have a P
and a K
, followed by the byte values 5
and 6
and then a bunch of zeros. That’s what an empty ZIP file looks like when it’s first created.
What it all means is unimportant. The P and K probably have to do with Phil Katz, one of the early ZIP utility pioneers. The 5 and 6? Who cares! The zeros? I dunno! But all put together, the thing represents an empty ZIP file, which would be easy to duplicate.
The next task is to create a script that can be fed into the DEBUG
utility, a script that will use DEBUG
to recreate a ZIP file. You’ll read about that script in the next blog post.
This is getting very interesting. I normally use zip or tar on linux, but on Windows I only have WinRAR.
Comment by samus250 — June 4, 2009 @ 11:05 pm
I find spelunking into an operating system to be fun and interesting. I did a whole book called Underground DOS that did basically that.
Comment by admin — June 5, 2009 @ 8:57 am