Managing archive/image formats on macOS using the Terminal

Anything about Mac emulation that does not belong in the above categories.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
uyjulian
Apple Corer
Posts: 244
Joined: Fri Aug 27, 2010 1:02 am

Managing archive/image formats on macOS using the Terminal

Post by uyjulian »

There are ways to convert between various archive and image formats on macOS using the Terminal.

"The Unarchiver" supports Stuffit (.sit), Stuffit X (.sitx), MacBinary, BinHex, along with many other archive formats, and it has a command line tool: https://theunarchiver.com/command-line

To use it:
unar file.sit

It also extracts resource forks and Finder Info, so you don't lose any information.
You can use the following command to check resource fork and Finder Info information:
ls -@l /path/to/file/or/folder

Check for the presence of "com.apple.FinderInfo" and "com.apple.ResourceFork" attributes.

You can create .tar.gz files with extra attributes (including resource forks and Finder Info) using this command:
tar -czf /path/to/archive.tar.gz /path/to/file/or/folder

You can convert into MacBinary II using macbinary tool:
macbinary -t 2 encode -o /path/to/macbinary.bin /path/to/file

You can convert NDIF, DiskCopy 4.2, Toast disk images, macOS DMG images, etc:
hdiutil convert -format UDxx -o /path/to/output/image.img /path/to/input/image.dmg
The format UDxx will work with emulators, but there are many other formats you can convert to.
Run:
hdiutil convert -help
for a listing of the formats you can convert to.
This tool won't work with DiskSet formats such as the ones used in the Mac OS 7.5.3 install sets (.smi/.part). You need to use Disk Copy 6.3.3 in an emulator to mount the image, then create an image from the mounted image.

You can "bless" a System Folder using the bless command line tool:
sudo bless -folder9 /path/to/System/Folder

You can also set a label that will appear in the menu when you hold down option while booting:
sudo bless -folder9 /path/to/System/Folder -label "Your Label"

You can run these commands in batch if you combine it with the find command. For example:
find . -name \*.sit -exec unar {} \;
will extract all Stuffit archives in the current directory.
find . -name \*.img -exec hdiutil convert -format UDxx -o {}.dmg {} \;
will convert all disk image files ending in .img to a format usable in emulators.
User avatar
adespoton
Forum All-Star
Posts: 4227
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Managing archive/image formats on macOS using the Termin

Post by adespoton »

I've been considering writing a wrapper app that just lets you select these options from a menu or button panel. Would anyone be interested in that?

I'd also add in my "sparserbundler" script that converts images to .sparsebundle images with 1MB file segments. These are great for using with emulators and Time Machine, as only the partitions that have changed get backed up. To compact the image when it starts to get large, you just run it through the sparserbundler droplet again and it drops all the unused segments.

Code: Select all

hdiutil convert "$1" -format UDSB -tgtimagekey sparse-band-size=2048 -o "$1-1Mb.sparsebundle"
User avatar
SistemaRayoXP
Tinkerer
Posts: 82
Joined: Fri Oct 13, 2017 4:34 pm
Location: Mexico
Contact:

Re: Managing archive/image formats on macOS using the Termin

Post by SistemaRayoXP »

It would be great, as it's simpler than using a commandline
Hill radio station first attempt: Failure. Retrying...
Post Reply