2

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.

user6567
  • 21
  • 1

2 Answers2

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/
Alex Jones
  • 6,353
  • 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
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/
cas
  • 78,579