Zip a folder on Mac from Terminal
Create a clean zip archive of any folder, preserving macOS metadata.
Replace the two paths in the command below with your folder and the target zip, then run it. A standard zip is created on your Desktop.
01Command
Command
$ ditto -c -k --sequesterRsrc --keepParent ~/Documents/MyFolder ~/Desktop/MyFolder.zip02What it does
ditto is the macOS-native way to create zip archives that preserve resource forks and metadata, so files open correctly when sent to other Macs (and unzip fine on Windows too). --keepParent includes the folder itself in the archive instead of just its contents.
03Risk
!Warning: The command overwrites the target zip without asking if it already exists.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- ditto — copy directory contents and create archivesEvidence: ditto -c -k creates a PKZip archive; --sequesterRsrc preserves Mac resource forks.
Last verified: 2025-11-08 · Category: Files & Folders