I have a batch file that outputs a text file. I thought it would be nice if I could zip it up too.
This will be used in an uncontrolled environment, so I can't make assumptions about the presence of third-party software products such as 7-Zip, etc. This needs to use Windows' now-built-in capability to zip files.
Best Answer
Here is an all batch file solution (a variation of my other answer) that will zip a file named
c:\ue_english.txt
and put it inC:\someArchive.zip
:Write access is required to the parent of the folder stored in
TEMPDIR
. As this is often not the case for the root of drive CTEMPDIR
may have to be changed.Write access is also required for the folder the
.bat
script is in (as it generates a file there).Also, please note that the file extension for the compressed file must be
.zip
. Attempts to use another extension may result in a script error. Instead, generate the.zip
file and rename it.