How to create a .zip file for each folder within another folder

zip

Under the folder images\, I have the following folders:

  • Usa\
  • Italy\
  • Japan\

etc..

I want a script that creates a .zip for each of these folders, so I have usa.zip , italy.zip, japan.zip.

How can I do that?

Best Answer

I assume this is Windows, as you are using backslashes.

Get 7za.exe (the command-line version of 7-zip) and put it in your %PATH%.

Then run this within your Images\ directory:

for /f "tokens=* usebackq" %G in (`dir /b /a:d "%cd%"`) do 7za a -r -tzip "%~G.zip" "%~G"

Or in a batch script:

for /f "tokens=* usebackq" %%G in (`dir /b /a:d "%cd%"`) do 7za a -r -tzip "%%~G.zip" "%%~G"
Related Question