≡ Menu
Deep in the Code

Creating Compressed Files for Each Folder

I had quite a few folders that I wished to compress into ZIP files, all of which happened to exist in a single folder. In Windows, you can certainly compress multiple folders by selecting them all and then right-clicking and selecting “Send To” –> “Compressed (zipped) Folder”. However, this will put all folders into a single zipped file. What if I wanted each folder to have its own zipped file?

Using 7-Zip, I was easily able to do this.

Once 7-Zip is installed, open a Command Prompt and change to the folder in which all your to-be-compressed subfolders reside. The command below will create ZIP files, also in the main folder, from all those subfolders. The assumption here is that 7-Zip is installed in “C:\Program Files\7-Zip”; if it is elswhere change this attribute accordingly.

FOR /F "usebackq delims=?" %i IN (`DIR /B /A:D`) DO "C:\Program Files\7-Zip\7z.exe" a "%i.zip" "%i"

For some other options you can use, this post was of great help.

About the author: I solve problems. Solutions Architect / Senior Software Engineer / Business Analyst / Full-Stack Developer / IT Generalist