How to recursively zip every file in each folder?

0

I am trying to write a batch script that when run into a folder, it takes all the files in this folder and zip them into one, then takes the remaining folders and looks into them and do the same, saving the zip files into each folder.

Example:

folder1
   file1.ext
   file2.ext
   folder2
      file3.ext
      file4.ext

should become

folder1
   file1.ext
   file2.ext
   folder1.zip containing file1.ext and file2.ext
   folder2
      file3.ext
      file4.ext
      folder2.zip containing file3.ext and file4.ext

untore

Posted 2013-07-02T08:43:45.857

Reputation: 131

I have added an example to your question to make it better understandable. You did not specify what names the ZIP files need to have. Feel free to revert my edit. – Jan Doggen – 2013-07-02T08:47:06.510

1@untore What Windows version are you using? Maybe Powershell (Windows 7) is also an option? – nixda – 2013-07-02T08:53:28.363

Answers

2

WinRAR!

  1. Select all folders
  2. Right click> Add to Archive
  3. In WinRAR options go Files tab
  4. In the bottom Archive section, select "Put each file to separate archive"
  5. Ok.

Now every folder will be created into new RAR or Zip archive.

Jones

Posted 2013-07-02T08:43:45.857

Reputation: 1 213

0

If you have UNIX background you can install Cygwin and write a Bash script to descend directories recursively invoking a Cygwin zip command, or any other zip command line interface (CLI) program.

You can also install Python and that way is even simpler a script to recursive descent. Each step can make a call to a CLI zip program.

You can probably use the Powershell, but am not sure how easy can be used to recursive descending.

174140

Posted 2013-07-02T08:43:45.857

Reputation: 859