Previous Next | Up | Table of Contents | DropDMG Home

3.2.4   AppleScript

You can use AppleScript to automate DropDMG. For example:

-- create a new image from a folder
tell application "DropDMG"
    -- allow 2 hours before AppleScript times out
    with timeout of 2 * 60 * 60 seconds
        set p to "~/Desktop/folder" -- POSIX path to source folder
        --Specify the options using AppleScript parameters.
        create image from path p format NDIF compressed encoding macbinary
    end timeout
end tell

-- convert an image to another format
tell application "DropDMG"
    -- allow 2 hours before AppleScript times out
    with timeout of 2 * 60 * 60 seconds
        set p to "~/Desktop/image.img" -- POSIX path to source image
        -- Rather than specifying all the options in AppleScript, you
        -- can save them as a DropDMG configuration and refer to them
        -- that way.
        create image from path p configuration name "My Configuration"
    end timeout
end tell

You can view DropDMG’s AppleScript dictionary by dragging and dropping the DropDMG application onto Apple’s Script Editor. A collection of example DropDMG scripts is available. create image is the most commonly used command; it lets you make images and archives from folders, files, or other images. Whenever you use create image, you must always include the following parameter:

from path
This can be a POSIX path or an alias to a folder or file.

The remaining parameters are optional.

configuration name

Instead of specifying all the parameters in AppleScript, you can create a named configuration in DropDMG’s preferences window, and then just specify the name of the configuration in the script, as a string. If you do this, all of the options below, except always create, base name, and volume name are ignored. This is because the other options are specified as part of the configuration. If you specify the empty string ("") as the configuration name, DropDMG uses whichever options are currently set in the Preferences window.

always create
Normally, DropDMG will automatically determine whether to convert the source item to another format or to create a new image/archive containing the item. If conversion is possible, it will convert; otherwise, it will create. This option lets you tell DropDMG to create a new image/archive, even if conversion is possible. It should be either true or false. If no value is specified, DropDMG will automatically decide whether to convert or create.
format
This corresponds to the Format preference. Accepted values are: zlib compressed, bzip compressed, ADC compressed, read only, read write, NDIF compressed, NDIF read only, NDIF read write, self mounting, StuffIt X, tar archive, zip archive, and master. If no format is specified, DropDMG will choose zlib compressed.
encryption
This corresponds to the Encrypt using passphrase preference. It should be either true or false. If no value is specified, DropDMG will make the image unencrypted.
passphrase
If encryption is specified, you may also specify the passphrase with which to encrypt the image or archive.
segment size
This corresponds to the Limit segments to at most ___ MB preference. It should be a number, zero or greater, representing the number of megabytes per segment. If the value is zero or omitted, DropDMG will not segment the image.
encoding
This corresponds to the Encoding preference. Accepted values are: none, binhex, bzip2, gzip, and macbinary. If no encoding is specified, DropDMG will choose none.
license agreement name
This corresponds to the License Agreement preference. If the name is omitted or the empty string (""), DropDMG will not include a license agreement.
custom icon
This corresponds to the Use custom icon for mounted image preference. It should be either true or false. If no value is specified, DropDMG will not use a custom icon.
auto open
This corresponds to the Auto-open image window after mounting preference. It should be either true or false. If no value is specified, DropDMG will not make the image auto-open. This option is ignored when creating an image by converting.
internet enabled
This corresponds to the Internet-enabled (auto-copy instead of mounting) preference. It should be either true or false. If no value is specified, the image will not be Internet-enabled.
destination
This corresponds to the Save preference. This can be a POSIX path or an alias to a folder. If the destination is omitted, DropDMG will use the folder that contains the source folder or image. If the destination is the empty string (""), DropDMG will prompt you to choose a destination.
base name
This is the name of the image to create, without the .dmg, .img, or .smi extension. If the base name is omitted or the empty string (""), DropDMG will use the name of the source folder or image.
volume name
This is the name of the mounted image volume. If the volume name is ommitted or the empty string (""), DropDMG will use the name of the source folder. This option is ignored when creating an image by converting.
append current date
This corresponds to the Append Current Date preference. It should be either true or false. If no value is specified, DropDMG will not append the date.
sanitize for servers
This corresponds to the Sanitize for Servers preference. It should be either true or false. If no value is specified, DropDMG will not modify the name.
delete original
This corresponds to the Delete original after Creating or Converting preference. It should be either true or false. If no value is specified, DropDMG will not delete the source folder or image.
just package contents

Some Mac OS X files, such as a applications, are actually special folders called packages. The system presents packages to the user as a single file, but they’re actually stored on disk as folders. Normally, when DropDMG makes an image from a folder it copies the contents of the folder into the image; that is, the mounted image behaves just like the original folder did.

Since packages are folders, you can make images of them with DropDMG. However, if DropDMG proceeds as usual, when you mount an image that was created from a package, the Finder will think that the mounted image is a package. It will show the package icon instead of the disk image icon, but it won’t let you double-click the mounted image to access the package (e.g. launch the application). You might think that you could drag the mounted image to your hard disk to launch the application from there, but the Finder will create an alias instead (unless you know to hold down Option).

Therefore, by default, DropDMG recognizes when you are imaging a package and gives you a disk image with the package inside it, instead of making an image of the package. To disable this feature, and thus have DropDMG treat all folders consistently, pass true for this parameter.

Previous Next | Up | Table of Contents | DropDMG Home