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

Bulk convert DMGs to 'Internet enabled' format System

Apple's introduced what they strangely call "Internet-enabled" disk images. I say that "Internet-enabled" is a weird name because I don't see anything particularly "Internetly" about these disk images. As far as I can tell they simply extract their contents and go away. Little Snitch reports no Net activity by any of them. When you mount one, it dumps its contents into a folder (in same directory as the image, and with the same name, sans the .dmg), unmounts itself, and trashes itself. This makes software installation a lot more user-friendly (i.e., you can drag the folder with the enclosed app and documentation to Applications, instead of having to manually create such a folder - unlike under OS9, dragging the mounted image simply makes an alias, not copy, of the image and its contents.)

Only two problems:

  1. The vast majority of images on VersionTracker, MacUpdate, etc. are not "Internet-enabled"; and
  2. hdiutil, the commandline tool you can use to convert a .dmg to an "Internet-enabled" one, will not accept wildcards, only one file at a time (hdiutil internet-enable -yes *.dmg or hdiutil internet-enable -yes EV*.dmg just yield an error message). If you have a large download folder it could take you literally all day to convert them, kind of obliterating the time savings offered by the "Internet-enabled" disk image format.

This irritated me, so I blew a little time fixing the problem (for the most part). The script below will handle pretty much whatever you want it to. I called my copy hdi-ie.sh and put it in my ~/bin folder. To use it, I just open a terminal window, cd into my downloads folder, and do "hdi-ie.sh *.dmg", or if I want to be more specific maybe something like "hdi-ie.sh AACelerator1.0.dmg b*.dmg EV*.dmg BBEdit_stuff*bbedit*.dmg", and it works like a charm.

Known issues:

  • While it will handle filenames with spaces in them, certain other characters may need to be escaped on the Unix commandline, and so won't be handled correctly. Someone with some awk or sed skills could probably improve the script to solve that issue.
  • Not all .dmg files can be converted to the "Internet-enabled" form, but (so far as I've seen) the vast majority can.
  • I could have, but did not (yet) use hdiutil (or "open", for that matter) to force DiskCopy to process each of them while the script runs, and turn them all into folders.
Read the rest of the hint for the script and instructions on how to use it...

The Script:

#!/bin/sh

# hdi-ie.sh   ver. 1.1   2002-03-19   public domain freeware
# by Stanton McCandlish, <mech[@-sign goes here]well.com>
# Tells hdiutil to convert the named (wildcards are supported)
# .dmg disk images to "internet-enabled" format, so that they
# dump their contents to a folder and trash themselves when
# mounted.  Handy!
#
# Many thanks to VitaminMoo on XHintsChat for debugging help.
  
# Usage: hdi-ie.sh <file[s]>

if [$1 = ""]; then
 echo "Usage: hdi-ie.sh <file[s]>"
else
 for file in "$@"; do
   echo "$file"  # shows what the expanded values are.
   hdiutil internet-enable -yes "$file"
 done
fi

For total Unix newbies: To make use of this script, open the Terminal application (should be in /Applications -> Utilities). Type the following (each line followed with a return (or enter) keystroke), in the order they appear here:
cd ~
mkdir bin
cd bin
pico hdi-ie.sh
This starts up the pico text editor. Copy the above script, from (and including) "#!/bin/sh" all the way through "fi", and paste that into pico. Then do ctrl-x (to exit pico), answer "y" to the save question that appears, and hit return/enter key when asked if you want to accept the filename. You will now be back at the Unix prompt. Type "exit" (without the quotes) and hit return/enter to leave the Terminal session.]

Now, when you feel like converting some .dmg images, open a terminal window (a different one; the script will not be available to you unless you either type "rehash" (without the quotes), refer to the script by its path as well as filename, i.e. "~/bin/hdi-ie.sh", or launch a new terminal window other than the one in which you first saved the script in pico), then "cd" into the directory containing the offending disk images, and run them through the script ("hdi-ie.sh [file(s)] ").

    •    
  • Currently 2.80 / 5
  You rated: 1 / 5 (5 votes cast)
 
[14,543 views]  

Bulk convert DMGs to 'Internet enabled' format | 36 comments | Create New Account
Click here to return to the 'Bulk convert DMGs to 'Internet enabled' format' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Bulk convert DMGs to 'Internet enabled' format
Authored by: JoeGrind on Mar 21, '03 10:34:42AM
I guess this is too little too late for the author of this comment, but the command line 'find' tool is very underutilized.

find . -name \*.dmg -exec hdiutil internet-enable -yes {} \;

That will find all *.dmg files in a directory (and subdirectories) and run that internet-enabling thing.

[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: filburt1 on Mar 21, '03 11:14:10AM

The "Internet-enabled" reference is probably to things like Safari which now automatically mount/unstuff files when downloaded.



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: fredcondo on Mar 21, '03 12:36:31PM

You should quote the {} and must quote the ;

find . -name *.dmg -exec hdiutil internet-enable -yes "{}" \;

[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: JoeGrind on Mar 21, '03 03:30:23PM

Ahh.. Right you are. The html posting took that out.



[ Reply to This | # ]
Use the new tag...
Authored by: robg on Mar 21, '03 07:15:41PM

Use the [ code ] and [ /code ] tag pair (without the space inside the brackets, and Geeklog will leave all of the backslashes and angle brackets alone.

It's a pain, still, but better than it used to be.

-rob.



[ Reply to This | # ]
Use the new tag...
Authored by: mech_filter on Mar 22, '03 07:52:41AM

Wandering off-topic, but <CODE> is hardly "new". It's been part of HTML since before I was using HTML. And that began ca. Dec. 1993... Heh.



[ Reply to This | # ]

Use the new tag...
Authored by: Spartacus on Mar 22, '03 10:15:30AM

If you read carefully, you'd have noticed he talked about [ code ], not < CODE >. While the latter is HTML, the former is a feature of GeekLog (and of other software like UBB or phpBB). If Rob says it's new, I'd believe him. It's his website after all.



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: ajmas on Mar 22, '03 09:37:45AM
There should be a backslash before the semi-colon:

find . -name *.dmg -exec hdiutil internet-enable -yes "{}" \;

I have never needed to use the quotes when using the -exec command, though I will take you word for it.

[ Reply to This | # ]

Bulk convert DMGs to 'Internet enabled' format
Authored by: mech_filter on Mar 22, '03 07:49:37AM

Yes, I know, but that require remembering a complex commandline. I
like just typicing "hdi-ie [wilcards&filenames]" (yeah, I made an alias so
I don't even have to type the ".sh" extension on the script. Lazy, lazy,
lazy!



[ Reply to This | # ]
Another piece of a puzzle...
Authored by: Xenex on Mar 21, '03 10:38:16AM

A friend of mine recommended a PDF browser plugin from Schubert-it to me the other day, which works quite well. I looked around the rest of the site, and came across something called Disk Image Browser Plugin 0.1 (Proof of Concept Release).

Very intrigued, I downloaded it and read the ReadMe. I'll save you the trouble of downloading the file:

Disk Image Browser Plugin

Background

The default installation method on OS X is via a Disk Image. This has some decisive advantages, as preserving both HFS and UNIX metadata, compression without the need of proprietary software etc. On the other hand the installation process is a little bit awkward. You have to download the disk image, double-click it to mount it using Disk Copy, bear its icon bouncing, after installation trash the Disk Image file etc. This is where the Disk Image Browser Plugin comes to play.

What is this?

The Disk Image Browser Plugin is a browser plugin that automatically mounts the disk image whenever you click a link to one without the need to download the disk image file first. That means you can browse the disk or read a Readme before downloading the whole image, and install software right from the remotely mounted image. No image file remains to trash after you're done with it.

How is it installed?

Download the Disk Image Plugin from

http://www.schubert-it.com/download/diskimage-plugin.sit

and move it into the folder /Library/Internet Plug-Ins/
Restart your browser.

Why proof of concept release?

The Disk Image Browser Plugin currently appears to work reliably only with software distributed as part of a ".Mac" subscription. Other server's configuration often seem to be not suited for remote mounting of disk images. It is therefore not intended for general adoption. It demonstrates a more convenient way of distributing software on OS X though.

This software is provided as is without any guarantee. Copyright ©2002 Manfred Schubert.

I assume this is what the 'mysterious' Internet-enabled setting is for.

Now, perhaps Apple are releasing their Disk Image files on .Mac in this Internet-enabled format, but most others are not. It will be very interesting to see if this "mount online" idea is the way Apple want to go in the future in distributing software.

---
It's what's not there that makes what's there what it is.

[ Reply to This | # ]

How to get Apache to serve like this
Authored by: David on Mar 21, '03 12:33:29PM

This is \0\0\0\0\0\0\0\0how Apache serves the .dmg files so that this plug-in works.
There is a setting in /etc/http/mime.types. The line is:

application/octet-stream bin dms lha lzh exe class so dll dmg

So, the plug-in basically takes an octet-stream from the server and
then
translates it into a .dmg file. It looks like the plug-in stores the .dmg file
in cache.

---
www.AcornWebDesigns.com
Quality websites for inexpensive prices (Is that an oxymoron?)



[ Reply to This | # ]
How to get Apache to serve like this
Authored by: mech_filter on Mar 22, '03 07:59:06AM

Hmm. Would that have any negative effect for people who didn't have
this plugin installed?



[ Reply to This | # ]
Another piece of a puzzle...
Authored by: daniel_steffen on Mar 22, '03 12:04:12AM

This has nothing to do with "internet-enabled" disk images, it uses a capability of hdid that has existed at last since 10.1: mounting disk images over http.

I've certainly used this sucessfully to mount disk images from my own apache server, so it's not restricted to .mac accounts at all, but you may have to configure apache settings to get good performance, as detailed in the hdid manpage:

Mounting Images via HTTP
       In  addition  to mounting image files from local or remote
       mounted filesystems, one can also mount image  files  from
       HTTP  servers.   For  flat  image  files  (UDIF images, or
       AppleSingle/MacBinary encoded NDIF image files) mounting a
       image is a matter of passing the http:// URL to hdid:

              hdid http://server.company.com/Images/stuff.dmg

       If  the  image  file  to be served via HTTP is a dual fork
       NDIF image that is not encoded  into  a  flat-file  format
       such as AppleSingle, and the HTTP server is running on Mac
       OS X, dual fork files may be detected and supported.  Such
       dual-fork  files must be moved or copied using the Finder,
       ditto -rsrcFork, or some other  resource-fork-aware  tool.
       Properly  copied  dual-fork  files  on a UFS volume have a
       ._filename file in addition to the filename you see in the
       Finder (i.e.  stuff.img would also have ._stuff.img in the
       same directory).

       In either case, one would specify  the  URL  to  the  data
       fork, and hdid will determine if it is necessary to access
       the secondary file.

       Accessing dual fork files on HFS+ filesystems via HTTP  is
       only supported if the HTTP server is on a Mac OS X system.
       It is possible that some options on the web  server  could
       disable access to the resource fork on an HFS+ volume, but
       no such options have yet been found.

       Browsing images via HTTP is  much  more  pleasant  if  the
       server  settings  are  modified  to  be  more  friendly to
       highly-persistent clients.  In particular for Apache, Max-
       KeepAliveRequests should be increased significantly beyond
       100 or set to 0 (unlimited) and KeepAliveTimeout should be
       boosted  to  at least 30 (seconds).  Increasing the number
       of simultaneous clients may also be desirable  because  of
       the  increased  delay  before clients are forcibly discon-
       nected.

       While it is not directly related to mounting via  hdid(1),
       informing  your  web  server  that '.dmg' (and others) are
       extensions  associated  with  the   MIME   type   applica-
       tion/octet-stream  will allow web browsers to download the
       files rather than try to display them.   For  apache,  you
       add   the   extensions   to   the   appropriate   line  in
       /etc/httpd/mime.types.


[ Reply to This | # ]
Why not simply apply
Authored by: juanfc on Mar 21, '03 12:26:09PM
Try with

apply 'hdiutil internet-enable -yes' *.dmg

it allows you to be modified easily and all you need is a simple apply before the not-expand-wildcards-command.

---
---
juan

[ Reply to This | # ]

Huh? Why not simply apply
Authored by: mech_filter on Mar 22, '03 08:03:41AM

Not sure I'm following you.

A) I'm not sure where you want me to put this into the script - do you
mean to just replace the hdiutil line with your version exactly as you've
given it?

B) More to the point, I don't understand what benefit this would have;
the script already does exactly what it should (or at least what I
expected it to). Would it do something better with your edit? If so,
what?



[ Reply to This | # ]
Huh? Why not simply apply
Authored by: vajonez on Mar 22, '03 12:56:58PM
He means that with apply you don't need the for loop, and possibly wouldn't need the shell wrapper at all (since it is such a simple command).

[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: blueamoeba on Mar 21, '03 12:36:04PM

I have been using a small application called Special Move that converts
most .dmgs with a simple drag and drop. You can drop multiple files and
I have had no problems whatsoever. I found it on Macupdate or
Versiontracker



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: hamking on Dec 13, '03 12:36:51PM

Just to clarify:

Is an "internet ready" disk image an .iso?

or is it some other form of the .dmg image?

Thanks,
--Hamking :D



[ Reply to This | # ]
DMG to / from ISO??
Authored by: iu-macboy on Mar 21, '03 02:32:40PM
What about taking a DMG and creating an ISO? (or vice versa)

---



[ Reply to This | # ]

DMG to / from ISO??
Authored by: leamanc on Feb 27, '09 09:04:50PM

Well, this question was asked six years ago, but in case anyone is wondering still, it's very simple: change the extension from .dmg to .iso. Now, most (if not all) DMGs are HFS+ formatted disk images, so the system you mount the .iso on must be able to read HFS.

But I have done this trick to burn Mac disks on Windows and Linux. Those systems' disc burning apps generally won't recognize .dmg as a disk image format, but of course recognize .iso. They will burn the .iso fine as a HFS+ formatted CD/DVD.



[ Reply to This | # ]
More about internet enabled DMGs
Authored by: Spartacus on Mar 21, '03 03:14:44PM

I read this document about internet enabled disk images. It was pretty interesting.

http://developer.apple.com/ue/files/iedi.html

When you double click such an image, it mounts (hidden), copies its content, unmounts, marks itself as NOT internet enabled and goes to the trash. If you get the image out of the trash, you get a normal disk image that will simply mount when double clicked. Interesting behaviour.



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: carsten on Mar 21, '03 06:56:11PM

I find that "Internet Enabled" disk images are very annoying!

Now that they are here, whenever I download a disk image, I run a script right away to convert it back to a regular disk image before I open it. (See A script to shrink and compress disk images easily, which has the side-effect of stripping the so-called "Internet Enabled" feature from disk images).

This auto-uncompressing behaviour makes it impossible to archive or backup the image, or copy it to many other machines in it's nice (compressed or not) single-file format.

In my opinion this auto-uncompressing behaviour is a complete step in the wrong direction as far as the user-experience goes. Apple would have done better to rewite the dmg driver alogether, to make accessing dmg files just like opening a folders--no mounting of a "drive" container, just open and display the contents as if it were a read-only folder already.

Carsten Klapp

[ Reply to This | # ]

Bulk convert DMGs to 'Internet enabled' format
Authored by: vonleigh on Mar 21, '03 08:34:13PM

From the developer site "After copying the disk image's contents, Disk Copy unmounts the image, clears the internet-enabled flag in the .dmg file, and moves the .dmg file into the Trash."

So just drag it out of the trash and store. It's a prefectly normal .dmg file.



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: mickelsn on Mar 24, '03 06:13:37PM

I agree that handling of DMG files could be handled much better at
the OS level, as others have suggested...

But what I absolutely HATE about the "Internet-enabled" images is
the control that you give up. When I "mount" a disk image by opening
it, the LAST thing I expect is a software installation that modifies my
HD contents somehow (Apps folder, System folder, whatever). I
WANT CONTROL!!

And frankly, it's a security risk. Can you imagine what's going through
a Mac OS X virus writer's mind now?? I'd be salivating over auto-
installed disk images...

If nothing else, Apple should make a user-accessible preference at the
system level to IGNORE the Internet-enabled disk image. And it
should be set to IGNORE by default, with plenty of information about
potential security risks, etc.

Neil



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: mech_filter on Mar 22, '03 08:16:05AM

<shrug> It's just a matter of user preference, largely based on whether
you are a network admin or not.

Me, I find it utterly annoying the way .dmg files behave. Like you I do
(mostly in theory only in my case) appreciate the neatness of keeping a
software distribute as a single easily portable file. But I don't need to
port mine around, and the ridiculous amounts of time wasted manually
creating folders to put .dmg-housed stuff in that you want to actually
use, then hunting down the disk image on your desktop (why on earth is
there no Finder menu option "Unmount..." that pops up a dialog you can
pick stuff to unmount?!), THEN go find the .dmg file and trash that, etc.,
it really all just drives me nuts.

I do strenuously agree with your closing sentence. If disk images, like
StuffIt files if you have Aladdin's "True Finder Integration", simply
behaved like folders, both sides would be happy. The one simple fix
Apple could implement that would go a long way is making .dmg's
behave just like .img's or any other mounted volume - if I drag it to a
folder on my hard drive, it should copy its contents to a folder with the
same name as the dragged disk [image]. Why on earth they thought
anyone anywhere would ever find it useful for this action to instead
create an alias to the mounted image just entirely escapes me. Better
yet, they could do that and make it so that option-clicking (or whatever)
on an image does the same thing my script does, and just gets rid of the
image file w/o it ever being mounted on the desktop, that way we
wouldn't have to go track them down and unmount them.

Maybe in 10.2.5. I can dream, can't I?



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: vonleigh on Mar 24, '03 01:12:20AM

"why on earth is there no Finder menu option "Unmount...""

Just control click within the window of the opened disk image, then select eject.


v



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: jervidalo on Mar 24, '03 04:15:26PM

Or press command+E



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: robJ on Mar 21, '03 07:57:24PM
I think a couple of AppleScript droplets might be handy for this. These droplets will handle dropped files but will not work recursively if folders are dropped on them. Compile in Script editor and save as applications. Tested with OS X 10.2.4.

-- Set internet enabled to yes --
on open fileList
repeat with thisFile in fileList
set shellCommand to "hdiutil internet-enable -yes " & quoted form of POSIX path of thisFile
do shell script shellCommand
end repeat
end open


-- Set internet enabled to yes --
on open fileList
repeat with thisFile in fileList
set shellCommand to "hdiutil internet-enable -no " & quoted form of POSIX path of thisFile
do shell script shellCommand
end repeat
end open




[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: robJ on Mar 21, '03 08:01:02PM

I screwed up on labeling the second one - it should say:

-- Set internet enabled to no --



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: ultimanine on Mar 22, '03 06:57:16PM

Expanding on your AppleScript droplet:

on open fileList
repeat with thisFile in fileList
set shellCommand to "hdiutil internet-enable -yes "¬
& quoted form of POSIX path of thisFile
do shell script shellCommand
set shellOpen to "open -a '/Applications/Utilities/Disk Copy.app' "¬
& quoted form of POSIX path of thisFile
do shell script shellOpen
end repeat
end open

This one converts the image(s) and then opens the image in Disk Copy. If you want, you can set all your .dmg files to open with this droplet, so all your downloaded images are automatically converted to the Internet Enabled format and then opened.

(Note,

---
Macs and music:
saviors of society



[ Reply to This | # ]
Bulk convert DMGs to 'Internet enabled' format
Authored by: davidmorr on Mar 22, '03 01:21:13AM
This makes software installation a lot more user-friendly (i.e., you can drag the folder with the enclosed app and documentation to Applications, instead of having to manually create such a folder - unlike under OS9, dragging the mounted image simply makes an alias, not copy, of the image and its contents.)

This making an alias, of course, is one the the more bizarre aspects of the OS X user interface. If you drag a folder, it copies the folder. The same should happen for dragging a disk icon.

Nevertheless, there is an easy solution. Hold down the Option key while you drag the disk icon and it will copy it instead of making an alias.

David

[ Reply to This | # ]

Bulk convert DMGs to 'Internet enabled' format
Authored by: mech_filter on Mar 22, '03 08:25:05AM

True, but you still have to mount the darned thing, then go find it on the
desktop and unmount it, and trash it. Doesn't "solve my issue". :-)



[ Reply to This | # ]
.sitx as an alternative to .img
Authored by: mclbruce on Mar 22, '03 01:23:06AM

For convenience I would think that .sitx is a valid alternative to .img. DropStuff, which is free to .mac users, will create .sitx files. Just open it up and change the default from .sit in the preferences.



[ Reply to This | # ]
.sitx as an alternative to .img
Authored by: mech_filter on Mar 22, '03 08:26:59AM

Well, utlimately perhaps, but the point of my hint was to tell people a
way to deal with the unwieldy .dmg files they are downloading in the
present. :-)



[ Reply to This | # ]
re: .sitx as an alternative to .img
Authored by: mclbruce on Mar 24, '03 11:40:46AM

No offense intended. I just want to mention an alternative that some people may not know about.

I have talked with a couple of developers who prefer .img to .sitx because .sitx does not preserve window size or do background images in windows. So I expect .img will be around for a while.



[ Reply to This | # ]
Clarification for UNIX-newbies
Authored by: MasterUltan on Mar 22, '03 01:16:45PM

What is meant by "hdiutil ... will not accept wildcards" is that hdiutil only accepts one argument at a time. The term "*.dmg" stills undergoes shell expansion and a list of all .dmg files is sent to hdiutil. If you try "hdiutial attach *.dmg" in a directory with more than one .dmg file, you'll get the following error message:

hdiutil attach: image file already specified.

Which is generated when hdiutil sees the second argument.



[ Reply to This | # ]