This AppleScript script is very handy for the creation of different type of archives and disk images.
It’s one of those scripts I use almost daily: It’s sitting in the Scripts menu in the menu bar and from there it allows me easy access to important and useful archive and disk image formats. Unlike other programs this script does not try to gather every available format. Just the ones that are right for a given purpose.
Updated: Compatible with Mac OS X 10.10, 10.11 and – now finally also – macOS 10.12 (Sierra).
The script can create these archive/dmg types:
- tar, uncompressed
- tar, gzip-compressed (tar.gz)
- tar, bzip2-compressed (tar.bz2)
- tar, lzma2-compressed (tar.xz)
- xar, uncompressed
- xar, gzip-compressed
- xar, bzip2-compressed
- zip (two variants)
- 7z (lzma2)
- dmg, read/write
- dmg, read-only
- dmg, zlib-compressed
- dmg, bzip2-compressed
- dmg, Sparse Image
- dmg, Sparse Bundle
… and some more stuff:
- Add files to tar, cpio, pax, zip, 7z archives.
- Add files to read-only or compressed dmg via Shadow File (“shadow mount”).
- Convert one dmg format to another.
- Adjust dmg size.
- Zip, 7z and all dmg types optionally AES-encrypted.
- Change the password of a dmg.
- Choose compression level for archives and dmgs.
- Detailed settings for lzma2 compression (xz und 7z), including dictionary-Size, word size, multi/single threading, solid / non-solid / solid by filetype.
- Option to paste the precomposed command line into the Terminal, for more ad-hoc tweaking (see below).
It was an unpleasant surprise with a commercial Mac app, that made me write this script: The app destroyed all Mac metadata (like Extended Attributes, tags), without warning.
That’s why one of the main objectives of this script is the retention of all Mac metadata, no matter which archive type has been chosen.
Later on I added two methods that are not metadata-compatible (7z and zip via p7zip). In the GUI these are explicitly labelled with “No Metadata”. They are thought for two special use-cases:
- When AES-encrypted zip or 7z archives are needed.
- When the archive is targeted for platforms that aren’t Mac-metadata-aware anyway (for example Windows). This way the recipient, after unarchiving, gets clean files without the otherwise usual "._" Multipart garbage.
I’ve written a detailed manual, which is can also be accessed from the GUI.
Download the script and move it to the user Scripts folder
~/Scripts/, so it can be launched through the Script drop-down menu in the menu bar.
- Select on or more files/folders in the Finder and launch the script.
Choose archive type.
Choose the appropriate settings. Holding down the ⌘-key while clicking allows you to select/deselect multiple options. (Settings will be remembered for the next session.)
Choose destination directory.
The GUI is context-sensitive and only shows you options that actually make sense for the selected file. For example, if a dmg is selected in the Finder, the script will offer these options …
… and, with a tar or cpio archive as source file, these:
The script runs silently in the background and displays a status message when finished.
As you can see in the third screen shot, you can make the script run “visibly” in the Terminal as well:
- Run in Terminal: All commands are set to maximum verbosity and sent to the Terminal. This is especially useful for large-scale archiving operations, for monitoring the progress, or to track down errors.
- Paste into Terminal: The script will paste the entire command line into the Terminal, but without executing it. This is very handy if we want to add rarely used, esoteric options, which are not available in the GUI.1
Download (1.2.0 / 2017-04-23)
Compatibility: Yosemite, El Capitan, Sierra.
The script contains the following tools:
- p7zip, a 7-zip port. The script uses p7zip not only for 7z archives but also for gz, bz2, xz and partially for zip, because it’s multi-threaded, faster and more efficient than the traditional Unix tools.
Furthermore the script uses these tools, preinstalled with macOS:
- 1.2.0 [2017-04-23]
- Minor code cleanup.
- Minor UI text changes.
- Added note to the manual about existing archives with the same name/path.
- 1.2.0b2 [2017-01-30]
- Removed ASObjC-Runner dependencies --> Script compatible with macOS Sierra now.
- Last used settings now handled by NSUserDefaults --> Script now requires OS X 10.10 (Yosemite) or newer.
- Script bundle and distribution disk image code signed.
- Added Apple’s new LZFSE compression for disk images (only OS X 10.11 (El Capitan) or newer.).
- Updated included 7za binary to ver 16.02.
- Added dictionary sizes 384MiB and 1536MiB (new maximum) for all LZMA2 actions.
- Added “Max. 2 Threads” options to all actions that use 7za (better compression than fully multithreaded).
- Slightly changed the selectable word sizes for LZMA2.
- Changed fallback compression level (when none is selected) from 6 to 5.
- Added notification via Notification Center when script has started.
- 7zip Help now opens the online documentation.
- hdiutil Help now opens the man page in Preview.
- Updated the manual.
- Fixed a bug that prevented the options window from appearing when a disk image resizing action was selected.
- More descriptive error message when an archive with the same name already exists at the destination and we cannot append.
- Added error message when shadow file could not be found.
- Selection lists now frontmost.
- Changed many message boxes and dialogs and some list entries.
- 1.1.3 [2016-04-13]
- Removed invalid parameters
-mtafor .tar.xz (incompatible since 7z 15.09).
- Removed invalid parameters
- 1.1.2 [2016-03-29]
- Updated 7za. (Previous version no longer produced solid archives on El Capitan.).
- 1.1.1 [2015-03-24]
- Recompiled 7za.
- 1.1.0 [2015-02-19]
- More precise archive designations in the GUI.
- Added longer delay to Terminal paste function, since on Yosemite sometimes the Terminal was too slow to open timely.
- Added missing Terminal options when “Add to Existing Archive” was selected and the target archive is tar, cpio or pax.
- 1.0.0 [2014-10-03]
- Fixed an issue with dmg shadow mounting.
- 7za updated.
- 0.9.1 [2014-02-11]
- The file dialog window in “Add to archive” now works with the application “Default Folder”, if installed.
- 0.9.0 [2014-02-11]
- Replaced all cpio options by tar. Why? Cpio had the advantage to accept long filenames, contrary to ustar. Tar/ustar (as in pax) had the huge advantage to conserve hard-linked files, but it breaks with long filenames, which makes it unreliable. Now I found out that OS X’s tar (bsdtar) does handle long file names correctly, while at the same time conserving hard links and xattr like ustar. So, it seems to be the best of both worlds.
- Eliminated a bug where the creation of non-compressed archives failed if in the previous run two list options had been selected (for example a compression level and “Run in Terminal”).
- Discovered a problem with xar and updated the description accordingly (concerns hard-linked files).
- 0.8.5 [2014-01-28]
- Removed the cpio.7z from the list of formats because the presence of two LZMA2 formats (.xz, .7z) caused confusion among some users. To reenable it just copy the commented line in the script back into the list section.
- 0.8.4 [2013-11-17]
dittonow again with
--keepParent(cpio, zip). Otherwise top-level tags/comments may get lost at expansion. The property can be configured in the script.
- 0.8.3 [2013-11-13]
- Now renaming works also for dmg conversion without shadow files, if source and target are in the same folder.
- 0.8.2 [2013-06-13]
- “cpio – No Compression” works again (sometimes?).
- 0.8.1 [2013-06-02]
- Small fixes.
- 0.8.0 [2013-06-02]
- Major cleanup.
- New: Remembers last archive type.
- Fixed: Preservation of cpio, tar, pax suffixes if archive is compressed afterwards.
- Added: hdiutil conversion to all image formats.
- Added: hdiutil resize, compact .
- Updated description.
- 0.7.2 [2013-06-01]
- Fixed: Default archive type.
- Modified: hdiutil script for encryption.
- Modified: hdiutil chpass script .
- Uses ASObjC Runner now to show progress bar and other stuff.
- Shows elapsed time.
- Source name extension excluded from archive name.
- Changed: removed
--keepParentfrom ditto zip.
hdiutilconversion to zlib dmg.
- 0.7.1 [2013-05-31]
- Added: Disk Image Info.
- Added: Change password for encrypted Images.
hdiutilscript for encryption.
- 0.7.0 [2013-05-21]
- All essential functions implemented.
- Documentation updated.
- For example, if we want to use PPMD compression, instead of lzma2, we launch the script, set all desired options as usual and select “Paste into Terminal”. The script will paste the entire pre-composed command line into the Terminal and all we have to do is replacing
ppmdand then execute the command.