Zip a folder on Mac from Terminal

Create a clean zip archive of any folder, preserving macOS metadata.

macOSZip & ArchivesTerminalFilesLow risk
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.zip

02What 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

RiskLow risk
CompatibilitymacOS 10.11 El Capitan – 15 Sequoia
!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

Last verified: 2025-11-08 · Category: Files & Folders

06Related solutions