MacOS – How to zip from terminal without creating folder structure of path to folder

compressionfindermacosterminalzip

It is possible to zip a target folder with encryption by the terminal command

zip -er ~/Desktop/myzippedfolder.zip ~/Documents/myfolder/

However, the contents of myzippedfolder will be a folder called Users containing a folder called username containing a folder called Documents containing the folder myfolder and its contents.

Is it possible to zip the folder myfolder only such that when myzippedfolder is unzipped it contains only myfolder and its contents rather than the parent folders?

Best Answer

Simply…

cd to the correct directory first. For Example:

cd ~/Desktop

or alternatively, type cd [space], then drag your folder to terminal to auto-fill the path