Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Easily mount disk images with an AppleScript Desktop
Here's a trick I discovered a few weeks ago. It basically wraps a shell command into AppleScript to ease disk image mounting. Here's the translation of what I published on my French website...

Under Mac OS X, disk image processing is provided by a private framework: DiskImages.framework (in /System -> Library -> PrivateFrameworks -> DiskImages.framework). Thanks to this framework, you can burn a CD directly from the Finder. In the Terminal, hdiutil is used to communicate with it. You can, for example, mount a disk image typing:
hdiutil mount disk_image_name.dmg
What's the point? Just try it. Instead of having Disk Copy launch, mount the image, and then quit, hdiutil provides you with a seamless integration of disk image mounting without any app-launching.

Now, sure, it isn't great to go to the Terminal each time you need to mount a disk image. So let's make an AppleScript wrapper for this command:
tell application "Finder" to set filelist to selection as list

repeat with aFile in filelist
if ((aFile as string) ends with ".dmg") then
do shell script ("hdiutil mount \"" & ¬
POSIX path of (aFile as string) & "\"")
end if
end repeat
Just save the script as a compiled script, and put it in ~/Library/Scripts if you use Apple's ScriptMenu (and want to use it from the menubar), or in ~/Library/Big Cat Scripts/Files if you use Big Cat (and want it to appear in the Finder's contextual menu), or wherever you wish if you use Key Xing (and want to launch it from the keyboard). You'll just have to select any number of disk images in the Finder and launch the script. You'll be done very fast.

(For those who prefer to use SNAX, there is currently no way to use this script. SNAX doesn't load Big Cat's contextual menu, and version 1.2.8 is unable to provide a list of selected items anyways. Steve Gehrman, SNAX's author, is aware of the problem and will try to fix it in the next version.)
    •    
  • Currently 1.50 / 5
  You rated: 1 / 5 (4 votes cast)
 
[21,043 views]  

Easily mount disk images with an AppleScript | 2 comments | Create New Account
Click here to return to the 'Easily mount disk images with an AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
It can also mount .smi and .img images
Authored by: Gwenhiver on Jun 11, '02 12:11:55PM
hdiutil can also mount .smi and .img disk images. A revised script can be seen at the end of this page. I know the site's in French, but I'm sure you'll be able to pick the AppleScript part up… ;-) (I can't just update it here, because GeekLog eats my anti-slashs…)

[ Reply to This | # ]
perhaps make it a droplet
Authored by: garbanzito on Jun 14, '02 03:14:17AM

nice idea. another approach would be to make it a droplet. also "quoted form" will be more flexible with odd characters in the file name. save as a stay open application to avoid having to wait for the droplet to launch:

-- if files dragged on
on open (the_files)
repeat with a_file in the_files as list
if {".dmg", ".smi", ".img"} contains (text -4 through -1 of (a_file as string)) then
do shell script "hdiutil mount " & quoted form of POSIX path of a_file
end if
end repeat
end open

-- if user double-clicks
on run
set f to (choose file with prompt "choose an image to mount") as list
open (f)
end run



[ Reply to This | # ]