How to Zip in the Command Line in Windows
Command line functions can speed up common processes for those who are familiar with the text-only interface. Even though Windows supports ZIP file compression using the Send To command, that command is not available in the standard Windows command line. Third-party compression tools, such as 7-Zip and WinZip, offer command line functions to speed up the compression process. Microsoft also provides a command line compression utility for Windows XP and Windows Server 2003 Server. Each tool will use its own command line syntax for compressing files.
Things You'll Need
- ZIP compression program
- Windows Server 2003 Resource Kit Tools
Download and install a third-party ZIP compression program with command line functionality. Two examples are 7-Zip and WinZip. Ensure that you download the correct version and any add-ons necessary to use the command line. For example, 7-Zip has a command line version of the program and WinZip has a separate add-on for licensed users.
Click the Windows "Start" menu button on the left of the task bar and click "Run."
Type "cmd" in the Open field and click "OK." A command window opens.
Type in the command line to compress the files into the ZIP format, according to the syntax of the ZIP compression program you are using. For example, in 7-Zip the command line may look like this--"C:\>7za a test.zip test.txt"--where "C:\>" is the directory where the 7-Zip command line program file is located; "7za" calls the executable file; "a" is the Add command; "D:\test.zip" is the destination and name of the ZIP archive you are creating; and "D:\test.txt" is the file you are adding to the archive.
Press the "Enter" key on your keyboard. The files are compressed into a ZIP archive and the final message in the command window is "Everything is OK."
Tips & Warnings
- Ensure that the drive in the command line is set to the same drive that holds the ZIP compression program. Otherwise the program will not be found.