If you want to store all the files in folder
under their name without a directory indication, you can use the -j
option.
zip -j folder/artifact.zip folder/artifact1.app folder/artifact2.ext2 folder/artifact3.ext3
or
zip -j folder/{artifact.zip,artifact1.app,artifact2.ext2,artifact3.ext3}
If you have files in subdirectories, they won't have any directory component in the archive either, e.g. folder/subdir/foo
will be stored in the archive as foo
.
But it would probably be easier to change to the directory. It's almost exactly the same amount of typing as the brace method aboe. If you do that, if you include files in subdirectories, they'll have their relative path from the directory you changed into, e.g. folder/subdir/foo
will be stored as subdir/foo
.
(cd folder && zip artifact.zip artifact1.app artifact2.ext2 artifact3.ext3)
For interactive use, you lose shell completion this way, because the shell doesn't realize that you'll be in a different directory when you run the zip
command. To remedy that, issue the cd
command separately. To easily go back to the previous directory, you can use pushd
and popd
.
pushd folder
zip artifact.zip artifact1.app artifact2.ext2 artifact3.ext3
popd
If you want full control over the paths stored in a zip file, you can create a forest of symbolic links. Unless instructed otherwise, zip
doesn't store symbolic links.
-j
would apply, and that'd compress all folders into a single root-level directory within the ZIP. That's not what you're looking for, is it? – phyrfox Nov 27 '15 at 11:02