Possible Duplicate:
Create an archive from a directory without the directory name being added to the archive

I would like to zip all content and folders from a folder to a ZIP file.

I have a folder 1 with the folder update in it. The contents of \update\ should be zipped so that those files and folders are in the root of the zip file update.zip. I still want to run the cmd command from inside folder 1.

Now I have this command:

7za a -tzip update.zip "update"

It zips the update folder too, but I don't want that to be included. The command should work under Windows XP and Windows 7.

link|improve this question
feedback

closed as exact duplicate by afrazier, studiohack Nov 1 '11 at 16:59

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

2 Answers

You could try to use the following syntax to do this:

cd update
7za a -tzip ..\update.zip *
link|improve this answer
Welcome to Super User! Can you explain how your change works? – Tom Wijsman Nov 1 '11 at 14:57
The OP has specified that they want to run the command from folder 1. – slhck Nov 1 '11 at 15:00
feedback

From the 7-Zip Help:

7z a archive2.zip .\subdir\*

adds all files and subfolders from folder subdir to archive archive2.zip. The filenames in archive will not contain subdir\ prefix.

So in your case it'd be: 7za a update.zip .\update\*

Also, pay attention to how 7-Zip deals with wildcards -- it's not the same as other Windows apps. It uses * to mean "All files", and *.* means "All files with a period in the filename". The primary difference being that with *.*, files without an extension are not included!

link|improve this answer
Thx for the answars both!! I finally got it working:D I used: 7za a -tzip ..\update.zip -x!*.exe ;i did have to copy 7za.exe to update folder to get it working. I did ad the command -x!*.exe to exclude the 7za.exe from the update.zip I will try the second option 2:D – UtCollector Nov 1 '11 at 19:15
Putting the 7-Zip executable somewhere in your system path would help too. – afrazier Nov 1 '11 at 19:27
Yes for my personal use i would putt the 7-zip.exe in my system dir. Thx – UtCollector Nov 1 '11 at 20:43
After a nother bit of testing i went for the other command: 7za a -tzip ..\update.zip * I did have to ad the tzip option to get a zip file that i could open. Thx both:D – UtCollector Nov 1 '11 at 20:45
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.