To Create a batch to archive and delete a folder, first, we need 7zip to be installed on your computer. You can download the latest version of 7zip here.

After installing 7zip, save following commands to a text file and save it as archive.bat :

@echo off

rem Echo what exactly we are doing
echo "C:\Program Files\7-Zip\7z.exe" a -r -tzip "" -mx9 "%~f1\*.*"

rem Run 7zip with arguments
"C:\Program Files\7-Zip\7z.exe" a -r -tzip "" -mx9 "%~f1\*.*"

rem Delete folder silently
rem rmdir /s/q %~f1


Caution: If you don’t have 7zip installed on your computer, this script will only delete your folder. So I added rem in front of delete folder line. After testing that this script works fine on your computer, you can remove rem in front of rmdir line (one before last line) to enable deleting of folder.


Drop any directory on the batch file, it will create a zip archive and delete that folder.

Similarly, you can use -mx0 argument to just store your folder without compression.

If you don’t want to delete your folder just remove rmdir line.

If you liked this post, please share it! Enjoy!