How to Zip a Folder Using a Batch File in Windows 10

In this article, I will show you how to Zip a folder using a batch file in Windows 10. For this, I will use 7-zip software.

What is 7-Zip?

7-ZIP is an open-source file manager that can compress folders in a variety of formats, including ZIP, BZIP2, GZIP, etc. You can also use this to decompress the file. Usually, it is used in the context menu of files and folders from where you can compress or decompress folders. However, you can also zip or unzip through the command-line interface. You can create a batch file and run the cmd to compress the folder.

Here’s why you should consider using 7-Zip:

  • Free-Use it without money. High compression rate-For ZIP and GZIP formats, 7-Zip has a better compression rate than PKZIP and WinZip.
  • Free for commercial use-7-Zip is protected by the GNU LGPL license, which allows you to legally copy and redistribute the software.
  • Localization: The software is available in 87 languages.
  • Windows integration: 7-Zip is compatible with Windows shell.
  • Security: The software uses AES. Encryption system of 256 files.

Zip a folder using a batch file in Windows 10

  • Firstly, download and install 7-Zip if you don’t have it on your PC.
  • Now, create a batch file for zipping a folder. To do that, open the Notepad app and enter the below script:
How to Zip a Folder Using a Batch File in Windows 10
Create a batch file

echo on

for /f “tokens=3,2,4 delims=/- ” %%x in (“%date%”) do set d=%%y%%x%%z

set data=%d%

Echo zipping…

“C:\Program Files\7-Zip\7z.exe” a -tzip “C:\”

echo Done!

Let’s checkout the commands used in the above script:

  • The leading line is used to indicate the “date” when the postal code name was created.
  • “C:\Program Files\7-Zip\7z.exe” is the installation path of 7-Zip on your computer.
  • You need to use commands to add files to the output zip archive folder.
  • “C:\” is the path where I want to save the file.
  • “C:\MyDocuments\*.doc” is the location of the folder I want to compress.
  • I use .doc because I only want to archive .
  • Doc files from the source folder.
  • If you need to compress all the files in the folder, just type “C:\MyDocuments”.
  • After writing the script, choose “File”> “Save As” and save it with a .bat extension.
  • Just select “All file types”, add .bat after the file name and click the “Save” button.
Save as .bat and tap on Save

Now, find the created batch file and double-click on it to execute the zipping script. An archive folder will be created in the specified location

Zipped files


That’s all! How to Zip a folder using a batch file in Windows 10. Just follow the instructions and your folder will be compressed. Hope you find this guide useful and visit our website for other guides. …

More to read:

How to Hide your Donations on Facebook

How to Silence an Android Mobile Automatically While Charging

How to Enable picture-in-picture in YouTube

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: