7-Zip is a free and open source archive manager that lets you compress folders in various formats including ZIP, BZIP2, GZIP, etc. You can also uncompress an archive using it. Usually, it is used from the context menu of files and folders from where you can compress or decompress folders. However, it can also be used through command-line interface to perform zipping or unzipping tasks. You can create a batch file and compress a folder by running it through CMD.
How to Zip a folder using a Batch file
Firstly, you need to download and install 7-Zip if you don’t already have it on your PC.
Now, you need to create a batch file for zipping a folder. To do that, open the Notepad app and enter a script like below: Let’s checkout the commands used in the above script:
The initial lines are used to declare “date” for creating zip name.“C:\Program Files\7-Zip\7z.exe” is the path where 7-zip is installed on your PC. If it is installed elsewhere, provide the respective path.a command is mandatory in order to add files to the output zip folder.“C:\twc.zip” is the location where I want to save my archive.“C:\MyDocuments*.doc” is the path to the folder which I want to compress.I have used .doc because I want to archive only DOC files from the source folder. If you want to zip all files from the folder, write only “C:\MyDocuments”.
After typing the script, click File > Save as option and save it with .bat extension. Simply select All file types, add .bat after filename, and click the Save button.
Now, go to the created batch file and double-click on it to execute the zipping script. It will create an archive folder in the specified location.
Hope you find this tutorial to zip a folder through a batch script in Windows 10 easy.