I have the following folder structure


I want to zip the content (files and sub folders) of folder without including the root folder in the zip.

I have tried command

zip -r package.zip folder

But this includes the root folder. Also tried the following form

zip -j -r package.zip folder

But this will flatten all the directory structures and just include the files. How do I preserve the internal directory structure but ignore the parent folder?

2 Answers 2


zip stores paths relative to the current directory (when it is invoked), so you need to change that:

(cd folder; zip -r ../package.zip .)
zip -r package.zip folder/*

The above command will zip all files and sub folders under folder directory (It will ignore the parent directory for folder)

  • This will store the folder/ path in the archive, which the OP doesn’t want. It will also ignore any hidden files inside folder. Oct 7, 2021 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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