I want to zip a directory using the batch file command (Windows XP batch file).
For example, if I want to unzip a file means I can use the jar -xf file.zip
(java) bat file command.
Like that I want a command line batch to zip a directory.
To begin a session, open a terminal window. Invoke the version of 7Zip you are using by entering "7z" for P7Zip (7z.exe), or "7za" for 7Zip for Windows (7za.exe) to start either the P7-Zip or 7za application prior to entering commands.
If you open a terminal console in the parent directory, or used the cd command to navigate there from the command line, you should then be able to run the command on the folder. The syntax is ' zip -r <zip file name> <directory name> '. The '-r' option tells zip to include files/folders in sub-directories.
Syntax: $zip -d filename. zip file. txt.
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
Yes, we can zip and unzip the file/folder using cmd. See the below command and simply you can copy past in cmd and change the directory and file name
To Zip/Compress Filepowershell Compress-Archive D:\Build\FolderName D:\Build\FolderName.zip
To Unzip/Expand Filepowershell expand-archive D:\Build\FileName.zip D:\deployments\FileName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With