June 8, 2009

Your Very Own ZIP File Creator, Part IV

Filed under: Main — admin @ 12:01 am

Time to automate DEBUG to spew out a new ZIP file at will. Yes, this is nerdy and technical stuff. Proceed with caution!

The DOS command line is modeled after the Unix command prompt. DOS does share some of the basic input/output elements of Unix, including the ability to feed text into a program. The topic is I/O redirection, and it’s kind of a lost art these days.

From the last post, you recall that you could create an empty ZIP file using the DEBUG utility in DOS. The problem is that it requires a lot of typing. Computers are supposed to make things easier, so why not do all that typing just once and let the computer worry about repeating itself?

The trick is to save your typing in a text file. You can then use I/O redirection at the command prompt to feed your typing into the DEBUG utility, thereby instantly creating a ZIP file.

Here is the text:

e100 50 4B 05 06 00 00 00 00 00 00 00 00 00 00 00 00
e110 00 00 00 00 00 00
rcx
16
n new.zip
w
q

Each line is a series of commands typed into DEBUG. The first two lines create the bytes needed for a raw ZIP file. The next two lines set the file size and name. The W writes the file, and — most importantly — the q quits DEBUG.

Now I’ll tell you a secret: I actually didn’t type in all that stuff: I just copied and pasted it from the Command Prompt window straight out of DEBUG! I pasted it into a Notepad window:

notepad1

You should do the same: Copy and paste the text into Notepad. Then save the file to disk with the name zip-create.debug, or whatever name you choose. The name doesn’t matter, but remembering the name — and the file’s location — is important.

The file location is important because you’re going to use this file later as part of a batch file. It’s the batch file that’s going to make creating the MKZIP utility possible. For now, you’re just automating the way DEBUG can be used to create a ZIP file.

By the way, I create and save all my batch files, and scripts like zip-create.debug, in a folder called commands, located right off my account folder in Windows. You might consider creating a similar folder for the account folder on your PC.

After saving the file, you can use it to create a ZIP file. Follow these steps:

1. Open a command prompt window.

2. Navigate to the folder where you saved the zip-create.debug file.

See? I told you that you’d need to remember where you saved that file. At the command prompt, the CD command is used to change folders (directories). If you’re totally lost now, then you’re totally lost; keep reading anyway.

3. Type DEBUG < zip-create.debug and press the Enter key.

(If you see an error message, then you’re not in the proper folder.)

The text from the zip-create.debug file is spewed into DEBUG just as if you typed it yourself. The end result is a new ZIP file named NEW.ZIP.

Of course, it isn’t really hard to keep recreating the NEW.ZIP file. The end result of my efforts was to create an MKZIP command. To do that, you need to employ batch files, which is the topic of Wednesday’s post.

2 Comments

  1. Wow, helpful. Does this mean I can create ZIP files in a hex editor or on an XT computer?

    Comment by linuxlove — June 8, 2009 @ 7:53 am

  2. Theoretically, yes. I’ve not tried it myself on another platform. But as long as the filetype is recognized and the contents need not be altered, I assume that it would work anywhere.

    Comment by admin — June 8, 2009 @ 12:12 pm

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.


Powered by WordPress