zip a folder

Hello, I simply want to zip a folder on my desktop and I can’t find anything relating to that in any dictionary. Do somebody have the command to do that?

Thanks in advance!

I wrote a script to add a password when zipping files, it was discussed here but the direct link is :

https://mac4translators.blogspot.com/2017/12/putting-password-on-zip-files-with.html

The simplest method to archive a folder is to select it in the Finder or on the desktop and then to select the compress-folder command from the context (right-click) or top File menu.

If the OP has some particular archive requirements, or just FWIW, the following is a simple script that mimics the behavior of the Finder compress-folder command. After prompting for the folder to be compressed, the script creates an archive of the selected folder in its parent folder.


--Prompt for source folder.
set selectedFolder to choose folder
set selectedFolder to POSIX path of selectedFolder

--Set variable to path to and name of archive file.
try
	set archiveFile to text 1 thru -2 of selectedFolder
on error
	display dialog "Folder selection error." buttons {"Cancel"} with icon stop
end try

--Create archive file (credit to brandelune).
do shell script "cd " & (quoted form of selectedFolder) & "; zip -r " & (quoted form of archiveFile) & " *"