Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add folder to subfolder inside existing zip file

Tags:

linux

shell

zip

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

like image 669
seppel Avatar asked Oct 05 '17 09:10

seppel


People also ask

Can you create a folder within a zip folder?

The Create a Folder dialog will appear. The dialog shows the full path of the folder in the Zip file in which the new folder will be created. Enter the name of the new folder in the Name field and then click OK. Files can now be dragged from Windows Explorer and dropped into the new folder.

Can you add files to an already zipped folder?

In Windows, once you've created a zip file you can then add more files to it by dragging them onto the zip file's icon.


1 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.

like image 97
nbari Avatar answered Sep 28 '22 02:09

nbari