Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have project with the usual directory structure (src/, bin/, ...), i.e

|-- bin
|-- lib
|-- src
`-- Makefile

And would like to create an archive with the following directory structure:

|-- bin
|-- lib
|-- src
`-- Makefile

Is there a neat way to do this, which avoids creating a temporary directory project-name/ elsewhere, then copying the files inside a finally calling zip -r ... on that temporary directory?

(I am basically looking for some kind of path prefix or relative path option.)

share|improve this question
up vote 5 down vote accepted

Maybe this already occurred to you, but why not just use a sym link rather than copy everything?

ln -s project-name project-name-version

then use zip -r through the sym link (zip will dereference sym links by default)? When you're done you can simply rm the sym link. Perhaps it's not the most elegant solution, but I don't know an obvious way to do it through zip directly.

share|improve this answer

This is more an advice than an answer: use Git!

If you setup a Git repository for your project, the whole thing become quite straightforward:

git archive HEAD --prefix=project-name-version/ \
    --format=zip -o
share|improve this answer
Excellent advice, thank you. git archive documentation: – Meglio Jul 12 '15 at 4:53
While using version control is a good idea, this answer does not match the question for the generic case. – Raim Apr 20 at 14:16
@Raim "This is more an advice than an answer: use Git!" written there since like 4 years, thank you for pointing it out... – cYrus Apr 20 at 14:24
If this was not intended as an answer, it should be converted to a comment. – Raim Apr 20 at 15:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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