10.6: Automate the creation of ISO images

Jul 29, '10 07:45:00AM

Contributed by: ChrisAMS

Snow Leopard only hintI love Disk Utility, however, it does not directly support the creation of ISO 9660 images. It can create CDR images or CD/DVD master images. Those can be renamed to .iso files and are supported by most software. But that's inconvenient to say the least.

Some searching revealed that you can create ISO images using the Terminal through hdiutil.

The Terminal command is:
hdiutil makehybrid -o ~/Desktop/Diskimage.iso ${diskName} -iso -joliet

However that still leaves things complicated. So I put this in Automator by adding the 'Run Shellscript' action.

echo -n `date "+%Y-%m-%d - %H:%M:%S ->"` >> ~/iso.log
echo "Starting ISO creation" >> ~/iso.log

diskName=$(drutil status | grep "Name:" | awk '{print $4}')

echo -n `date "+%Y-%m-%d - %H:%M:%S ->"` >> ~/iso.log
echo "Device: ${diskName}" >> ~/iso.log

echo -n `date "+%Y-%m-%d - %H:%M:%S ->"` >> ~/iso.log
echo `diskutil umountDisk ${diskName}` >> ~/iso.log

echo -n `date "+%Y-%m-%d - %H:%M:%S ->"` >> ~/iso.log
echo "Starting copy action."

echo `hdiutil makehybrid -o ~/Desktop/Diskimage.iso ${diskName} -iso -joliet` >> ~/iso.log

echo -n `date "+%Y-%m-%d - %H:%M:%S ->"` >> ~/iso.log
echo "Done" >> ~/iso.log
This script finds the superdrive by drutil, then unmounts the disk by diskutil, then makes the actual iso image by hdiutil and logs the process in a log file in the user directory.

I made this a Service in the Application menu (Snow Leopard only). Now I run the Service and the disk image appears on my desktop, when the CD/DVD ejects, it's done.

[crarko adds: The original command with hdiutil was mentioned previously in this hint. The use of Automator to create a Service is a handy addition to that.]

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100527035147137