1

I'm very new to working with batch files but I'm trying to achieve the following

I have a folder C:\...\...\...\evidence In it are subfolders, the names of these can vary, can contain letters numbers and spaces. Let's say;

  • Equations
  • Microscopy
  • images
  • Data
  • 10052011

What I'd like to do is compress all the contents of the subfolder into a file {Subfoldername}.zip so Equations.zip in equations and delete the now zipped contents.

I can use native zipping or 7zip and I can work with vb if necessary.

Irshad
  • 3,071
  • 5
  • 30
  • 51
  • Let me make it clear. So you want to zip only subfolders, or all files (one by one) in the subfolders? – Happy Face Aug 07 '15 at 09:05
  • take a look at this - http://stackoverflow.com/questions/28043589/how-can-i-compress-zip-and-uncompress-unzip-files-and-folders-with-batch – npocmaka Aug 07 '15 at 09:37

1 Answers1

0

a look at the help output of 7za.exe is helpful. eg.

for /D %%a in (*) do (
  7za.exe a -r "%%a.zip" "%%a" && rmdir /s /q "%%a"
)

will iterate all folders, zip them recoursively, and then remove them if zipping was successful (returned 0).

ths
  • 2,858
  • 1
  • 16
  • 21