• Status: Solved
  • Priority: High
  • Security: Private
  • Views: 45
  • Last Modified:

Batch or windows command: zip subfolders automatically

Hello Experts,

I have a FolderA which contains :
-Subfolder1
-Sufolder2
-Subfolder3

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:
-Subfolder1.zip
-Sufolder2.zip
-Subfolder3.zip

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

If you have questions, please contact me.

Thank you very much for your help.
0
LD16
Asked:
LD16
1 Solution
 
Pawan KumarDatabase ExpertCommented:
0
 
Bill PrewCommented:
Adjust the SET lines near the top as needed and give this a try.

@echo off
setlocal

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 [%%~nD.zip].
    "%ZipExe%" a "%%~D.zip" "%%~D\*.*" -r -tzip 1>NUL

)

Open in new window


ยปbp
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
Not batch but have a look at CircularLogFileArchiver. The main principle is the same
https://www.experts-exchange.com/articles/29108/Log-file-problem-CircularLogArchiver.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now