2

This question already has an answer here:

I want to create a zip archive from all files which are in "my_folder". Here is how I do it:

zip -9 -y -r -q  name.zip /home/user/Stack_Exchange/my_folder/

The problem is that right now when I unpack the archive, the hierarchy of folders is fixed, so the result of unpacking is the home folder and inside is the user folder, etc.

How can I create a zip archive which has only "my_folder" in the directory? I mean I want to see the folder "my_folder" after unpacking the archive.

marked as duplicate by Archemar, garethTheRed, X Tian, dhag, vonbrand Oct 15 '15 at 18:38

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.

0

Make the .zip file while in the directory above my_folder

e.g.

cd /home/user/Stack_Exchange
zip -9 -y -r -q  name.zip ./my_folder/
0

I think you are looking for -j option

From man zip

You may want to make a zip archive that contains the files in foo, without recording the directory name, foo. You can use the -j option to leave off the paths, as in:

zip -j foo foo/*

new command will be:

zip -9 -y -r -q -j  name.zip /home/user/Stack_Exchange/my_folder/
  • Won't this strip my_folder as well ? I think OP want my_folder/* , but not /home/user/Stack_Exchange/my_folder/* – Archemar Oct 15 '15 at 12:29

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