Batch or windows command: zip subfolders automatically

Hello Experts,

I have a FolderA which contains :

I am looking for a command line or a windows batch in order to automatically zip (with zip extension the various folders located in FolderA.

The idea is to have:

Application that I use to zip file is 7-zip.

If you have questions, please contact me.

Thank you very much for your help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
Bill PrewIT / Software Engineering ConsultantCommented:
Adjust the SET lines near the top as needed and give this a try.

@echo off

rem Define folder to process and location of 7-zip exe file
set BaseDir=B:\EE\EE29072200\base
set ZipExe=c:\_pf\7-zip\7z.exe

rem If base directory not found quit
if not exist "%BaseDir%\" (
  echo.*ERROR* - Base directory not found [%BaseDir%].
  exit /b

rem If zip program not found quit
if not exist "%ZipExe%" (
  echo.*ERROR* - Zip program not found [%ZipExe%].
  exit /b

rem process each folder under the base folder
for /d %%D in ("%BaseDir%\*.*") do (

    rem ZIP each folder into a ZIP file in base folder
    echo *INFO* - Creating ZIP file [].
    "%ZipExe%" a "" "%%~D\*.*" -r -tzip 1>NUL


Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaun VermaakTechnical SpecialistCommented:
Not batch but have a look at CircularLogFileArchiver. The main principle is the same
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.