I want to zip a directory using bat file command.
For example if i want to unzip a file means i can use jar xf file.zip
bat file command.
Like that i want command line code to zip a directory.
Install zip
sudo apt-get install zip
Zip your folder:
zip -r {filename.zip} {foldername}
Windows does not come with a command-line zip program, despite Windows Explorer natively supporting Zip files since the Plus! pack for Windows 98.
I recommend the open-source 7-Zip utility which includes a command-line executable and supports many different archive file types, especially its own *.7z
format which offers superior compression ratios to traditional (PKZIP) *.zip
files:
Download 7-Zip from the 7-Zip home page
Add the path to 7z.exe
to your PATH
environment variable. See this QA:
How to set the path and environment variables in Windows
Open a new command-prompt window and use this command to create a PKZIP *.zip
file:
7z a -tzip {yourfile.zip} {yourfolder}
If you have the Java JDK installed then you can use the jar
utility to create Zip files, as *.jar
files are essentially just renamed *.zip
(PKZIP) files:
jar -cfM {yourfile.zip} {yourfolder}
Explanation: * -c compress * -f specify filename * -M do not include a MANIFEST file