|If you are not experienced with using a command line interface you may first want to go over some of the information in Command Line Basics.|
To have WinZip Command Line Support Add-On create individual Zip files of each file in a folder, open a Command Prompt window and change directories (CD) to the folder where the files to be zipped are located.
|The examples below each have two lines. The first one defines the PATH to the WinZip folder. If you have already added this to the PATH environment variable, you will only need to use the second line.|
After changing directories, you can enter the following two lines in the Command Prompt window:
for %f in (*.txt) do wzzip %~nf.zip %f
Or enter the following two lines in a batch file:
for %%f in (*.txt) do wzzip %%~nf.zip %%f
If your filenames include spaces you will need to enclose the 2nd, 3rd, and 4th variable in quotes. For the example using the Command Prompt window it would now look like this:
for %f in ("*.txt") do wzzip "%~nf.zip" "%f"
|The examples above are specifically for text files (.txt). To work with other file types you would need to change *.txt to the appropriate file extension.|
It is also possible to create a set of Zip files where the contents of all of the subfolders in a folder will be zipped into individual Zip files. This set of commands contains a few steps and will not work directly from a command prompt. They will need to be saved in, and run from, a batch file.
REM create list of directories
DIR /AD /B >dirlist.txt
REM Zip contents of each directory
for /f "tokens=*" %%a in (dirlist.txt) do (
|Note: The final line above the ending parenthesis is the CD command followed immediately by 2 dots.|
Running the commands above as a batch file, will create a text file with the name of each directory (folder) on separate lines. The second section reads the text file, changes directories to the one on the line it just read, and performs the wzzip command once for each of these lines in the text file. The [PATH1] item should be replaced with the actual path to the parent folder, which contains the subfolders you want to zip. The [PATH2] item should be replaced with the path to the target folder in which you want to save your Zip files. Other switches can be added to the wzzip command, if desired. For example, you can add "-r -p" just after wzzip if the folders have subfolders inside and you want their contents added as well.
You may want to add a command at the end of your batch file to delete the dirlist.txt file. This is optional and would depend on your preferences.
If you have trouble with or questions about this please email Technical Support.