Wednesday, October 6, 2010

Creating And Upacking ZIP Archives Using Batch Scripts

Sometimes it's necessary to create archives and extract files from them with help of batch files. For instance, it's useful when you writing scripts for automated backups. There is a number of different console archivers available on market, but still the most famous one is PKZIP (together with unpacker PKUNZIP). This archiver is especially useful for those who still use DOS for some reason.
The following command will help you to compress all files in the current forder:
PKZIP -a -ex -r -P -whs %1 *.*
If you put this line to a text file and save it as 'zip.bat', then you should just call 'zip.bat c:\archive.zip' to compress all files from the current folder to c:\archive.zip.
To extract files from the created archive to the current folder, you have to use the following command:
PKUNZIP -d %1 -o .\
The only parameter passing to this short batch file is the name of ZIP to be extracted.

No comments:

Post a Comment

Translate