Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.zip" "%%X\"

What I get: XXX.zip > XXX(folder) > content
What I want: XXX.zip > 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 has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
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

1 Answer 1

try this:

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%~X.zip" "%%~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 "%%~X.zip" "%%~Y"
share|improve this answer
    
Thanks. The first code don't work, do 'XXX.zip>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 or ask your own question.