Create a Disk Image from a Folder with hdiutil
Turn an entire folder into a compressed .dmg disk image without any extra software.
Run hdiutil create with -srcfolder pointing at your folder to produce a single compressed .dmg file.
01Command
Command
$ hdiutil create -srcfolder ~/Desktop/Project -volname "Project" -format UDZO ~/Desktop/Project.dmg02What it does
UDZO writes a compressed, read-only image — ideal for archiving or sending a folder as one attachment. The -volname sets the name shown when the image is mounted. To make a writable image instead, use -format UDRW. Larger folders take a minute or two; hdiutil prints progress as it copies.
03Risk
!Warning: The .dmg is read-only; edit files in the original folder and re-create the image.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- hdiutil – Create and manipulate disk imagesEvidence: hdiutil create supports -srcfolder to build a read-only UDZO (compressed) image from a directory, and -volname to name the mounted volume.
- Create and work with disk images on MacEvidence: Apple documents disk images as a way to package folders into a single file that mounts like a disk.
Last verified: 2026-09-18 · Category: Files & Folders
06Related solutions
Create an Encrypted Disk Image with hdiutil
Build an AES-256 encrypted .dmg vault from the Terminal — no Disk Utility clicking required.
Find files larger than 500 MB on Mac
List the biggest files in your home folder that are eating disk space.
Show file extensions for all files on Mac
Make Finder display .pdf, .docx, .png and every other extension at all times.