how to add folder to subfolder inside existing zip file

Viewed 10971

I want to achieve the following (simple) task, but I don't know how...

I have a zip file like this, only containing some folders

dummy.zip:

/my/dummy/folder/stucture

how can I add folders to this dummy.zip file that the newly added files and dirs are located under "/my/dummy/folder/stucture" using the command line (linux)?

dummy.zip should look like this afterwards:

/my/dummy/folder/stucture/my/new/Dirs

I've made a screenshot to better illustrate what I mean

2 Answers

To append "archive" to an existing zip file you could use option -r:

zip -r9 dummy.zip dirs

You could crate your zip:

$ zip -9 dummy.zip file

And later you could add a full dir:

$ zip -r9 dummy.zip dirs 

Or contents of the dir on the same root:

$ cd dirs
$ zip -r9 dummy.zip *

The -9 is the compression level, in this case, the maximum.

If you have the original folder which you generated the first zip from, you can add the folder/files you want and then use the option -u from the zip command.

This option will update the zip with the newly added folders and files, you can use it like:

$> mkdir /my/dummy/folder/stucture/my/new/Dirs
$> zip -u dummy.zip /my/dummy
Related