enrii.blog

A passionate programmer’s findings in the world of internet.

Zip a Folder Using Command Line

Wednesday, June 6th, 2007

As far as I know, the built-in compressed zip folder function in Windows XP does not provide any command line tools. To zip a folder using batch script or command line, one can install command line tool provided by 7zip.

It can be done with installation of whole 7zip package or just use an executable file provided by 7zip. I prefer the latter option.

Download the "7-Zip Command Line Version" from 7zip download page and unzip it.

Use the following command to zip a folder:

7za a -tzip <archive-name> <folder-name>

e.g. 7za a -tzip test.zip "New Folder"

Although this seems to be quite useless to be run in command line, but it's extremely useful if you need to create batch script to automatically zip a folder. For my case, I need it to zip a folder and FTP it to a server. By this way, I can backup a folder to server without having to consider the recursive FTP upload problem.