June 10, 2009

Your Very Own ZIP File Creator, Part V

Filed under: Main — admin @ 12:01 am

Yes, this is the last part, where I go totally nerdy and discuss how to create your own MKZIP command for building fresh, empty Compressed Folders at the command prompt in Windows.

Some review:

I’ve discussed the raw content of an empty ZIP file, or Compressed Folder. How you can view that data using the DEBUG utility.

Then, I showed you how to use DEBUG to create your own, empty ZIP file.

Next, I showed you how to automate the process by creating text that can be fed into DEBUG to magically create an empty ZIP file.

So now you have the tool used to create an empty ZIP file, but you need the command that does the job. To create that command, you need to build a batch file.

I won’t bother discussing how batch files work or the technical nuances. Basically, here is the thing:

@echo off
rem MKZIP, create a new zip file/Compressed Folder
if "%1"=="" goto error
debug < %USERPROFILE%\commands\zip-create.debug > nul
echo %1 created.
goto end
:error
echo Specify the name of the ZIP file to create.
echo Be sure to include the ZIP filename extension.
:end

You must be very careful how you type line 5. That specifies the location of the zip-create.debug file. Above, I’m putting in my account’s commands folder. If you have it in another folder, specify the folder name.

The folder %USERPROFILE% is your account’s main folder on the PC.

I recommend creating the batch file using Notepad, unless you have a favorite text editor. Here’s how it looks on my computer:

notepad2

You need to save the file as a batch file, and you need to place it in a folder where you can have easy access to the file. What I did was to name the file MKZIP.BAT, modeling it after the MKDIR command to make a new folder (directory).

After pressing Ctrl+S in Notepad, choose the proper folder. I saved my file in the commands folder. Then type MKZIP.BAT as the name. From the Save as Type drop-down list choose All Files — do not choose Text Documents or Windows automatically appends the TXT extension, which isn’t a good thing.

After saving the command, you can run it! Assuming that nothing is screwed up, it should create a ZIP file for you like this:

MKZIP batch2.zip

Typing the above command at the command prompt on my PC creates a new Compressed folder named BATCH2.ZIP. That’s exactly what I wanted.

Another problem you’ll encounter is that the command works only in the directory it lives in. To make the command work everywhere, you need to add its directory to the search path. On my PC, the commands folder is already on the search path, which is handy because that’s where I put the zip-create.debug file.

I won’t bother going into search paths and directories at this point. That’s because I did warn you that this process would be nerdy and technical. Even so, I would recommend that anyone interested in exploiting the full power of their PC learn the command prompt or terminal shell.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.


Powered by WordPress