I use this current command that archives the folder "folder-root" and all it's content to a file named "site.zip":

zip -r site.zip folder-root/*

Problem is - I want to zip the contents of the folder and not the folder itself. Notice: I must issue the command from the current directory (ie - can't issue it from inside the folder).

How do I do that?

migrated from stackoverflow.com Mar 17 '13 at 1:26

This question came from our site for professional and enthusiast programmers.

This should do the job:

zip -rj site.zip folder-root/*

zip --help says:

-j   junk (don't record) directory
  • 3
    This will junk any subdirectory inside the directory as well. Not sure if that was wanted. – henko Oct 7 '13 at 8:54
cd folder-root

zip -r ../site.zip *

This question has a similiar problem and the answer could work. https://stackoverflow.com/questions/2597875/how-can-i-build-a-tar-from-stdin

zip site.zip `ls -1 folder-root/`

This will create the list of files that you want to add into your zip file.

  • Unless the files have spaces – jordanm Mar 16 '13 at 19:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.