Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have several folders and I need to compress the content of each folder in a separate ZIP file. However, every ZIP should only contain the content of each folder and not the folder itself.

The following code creates a file with the folder included. It is close to what I'm looking for, but I'm not there yet.

for /d %%X in (*) do  "c:\Program Files\7-Zip\7z.exe" a "" "%%X\"

What I get: > XXX(folder) > content
What I want: > content

How can I do this?

share|improve this question

marked as duplicate by Dave, nerdwaller, Scott, slhck Aug 21 '13 at 10:49

This question was marked as an exact duplicate of an existing question.

If you open a command shell and type "7z /?" it will give you a list of command-line parameters. I'm not sure exactly what you mean by "every zip compress only the content", do you mean that you want to have a separate zip file for each folder? – Taegost Aug 14 '13 at 15:06
Yes, I wish to have a seperate zip for each folder. BUT I wish to only compress the content of each folder (having so a ZIP of only what is inside the folder) and not the folder itself. I'll edit the main post (pardon my english) – Erues Aug 19 '13 at 9:49

try this:

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "" "%%~X\*"

and if this doesn't work:

for /d %%X in (*) do  for %%Y in ("%%~X\*") do "c:\Program Files\7-Zip\7z.exe" a "" "%%~Y"
share|improve this answer
Thanks. The first code don't work, do '>XXX(folder)>content' . The second one creates the zip's of each folder but each zip is empty. – Erues Aug 21 '13 at 7:24
@Erues the first command works fine here, for the second I made a fix. Please check your paths and the version of 7zip, current is 9.20. – Endoro Aug 21 '13 at 9:57

Not the answer you're looking for? Browse other questions tagged .