0

I saw the other links for some solutions but, I need to run the script for every folder under a main one but to give it its original name.

Example:

Main folder
    Folder 1
Folder 2
Folder 3

To output (in the same main folder)

Main folder
    Folder 1.zip
Folder 2.zip
Folder 3.zip

Thank you in advanced

Shabi Levanda
  • 11
  • 1
  • 1
  • check this - https://stackoverflow.com/questions/28043589/how-can-i-compress-zip-and-uncompress-unzip-files-and-folders-with-bat – npocmaka Jun 20 '17 at 05:46
  • Please read carefully ==> [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) ==> [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) ==> [What types of questions should I avoid asking?](http://stackoverflow.com/help/dont-ask) ===> [What topics can I ask about here?](http://stackoverflow.com/help/on-topic) – Hackoo Jun 20 '17 at 05:49

2 Answers2

0

You'll need zipjs.bat in the same directory as this piece of code:

@echo off

::Alter the line bellow with your parent directory
set "parent_dir=C:\Parrent\"

for /d %%a in ("%parent_dir%\*") do (
  call zipjs.bat zipItem -source "%%~fa"  -destination "%%~fa.zip" -keep yes -force no
 )
npocmaka
  • 55,367
  • 18
  • 148
  • 187
0

I have found a simple solution for this. Suppose you have multiple sub folders to be zipped in a folder. In that case, 1. Download and lnstall 7zip software. Then copy 7z.exe to the particular folder where you want to zip your subfolders.

in a notepad, copy and paste the following and save as .bat file. :

 cd "your_MainFolder_path" 

for /d %%f in do (7z a -t7z %%f.7z "your_mainFolder_path\%%f")

In case you want to keep the zip files and remove the original folders, add this after the for statement :

rd /s /q "your_mainFolder_path\%%f"