-- Disk Image Maker script v1.0.3 (c) 2025 -- I got sick of all of my disk image tools turning into abandonware, so I -- wrote my own disk image creation and conversion tool using AppleScript. -- .... AND NOW, YOU CAN TOO! https://www.whatsmyip.org/lib/applescripts/ global MyName on initialize() set MyName to "Disk Image Maker v1.0.3" end initialize on run initialize() set RunType to display dialog MyName & return & return & "This script can create a new disk image from a folder," & return & "or convert an existing disk image to a new format." & return & return & "Which would you like to do?" buttons {"Cancel", "Convert Disk Image", "Create from Folder"} with icon note default button 3 with title MyName if button returned of RunType = "Create from Folder" then set MyFolder to choose folder with prompt "Please choose a folder to create a disk image with:" CreateDiskImage(MyFolder) else if button returned of RunType = "Convert Disk Image" then set MyFile to choose file with prompt "Please choose a disk image file to convert:" of type {"dmg"} ConvertDiskImage(MyFile) end if end run on open x initialize() tell me to activate if (count x) > 1 then display dialog "ERROR" & return & return & "This script can only process one item at a time." buttons {"OK"} default button 1 with icon stop with title MyName return end if set DropType to (kind of (info for x)) if (DropType = "Folder") then CreateDiskImage(x) else if (DropType = "Disk Image") then ConvertDiskImage(x) else display dialog "ERROR" & return & return & "This script only accepts Folders (for disk image creation) or Disk Images (for conversion)" buttons {"OK"} default button 1 with icon stop with title MyName end if end open on CreateDiskImage(MyFolder) set SourceName to name of (info for MyFolder) set MyFormat to ChooseImageFormat() set MyEncryption to ChooseEncryption() set MyNewDMG to ChooseSaveFile(SourceName & ".dmg") RunCommand("hdiutil create -srcfolder " & (quoted form of POSIX path of MyFolder) & MyFormat & MyEncryption & MyNewDMG) end CreateDiskImage on ConvertDiskImage(MyFile) set SourceName to name of (info for MyFile) set MyFormat to ChooseImageFormat() set MyEncryption to ChooseEncryption() set MyNewDMG to ChooseSaveFile("New " & SourceName) RunCommand("hdiutil convert " & (quoted form of POSIX path of MyFile) & MyFormat & MyEncryption & " -o" & MyNewDMG) end ConvertDiskImage on ChooseImageFormat() set FormatList to {"[UDRO] Uncompressed (Read Only)", "[UDZO] zlib Compression", "[UDBZ] bzip2 Compression", "[ULFO] lzfse Compression (10.11+)", "[ULMO] lzma Compression (10.15+)"} set MyFormat to choose from list FormatList with prompt "Select a format for your new disk image:" default items "[UDRO] Uncompressed (Read Only)" OK button name "Select" with title MyName if MyFormat = false then error number -128 end if set FormatCode to (text 2 through 5 of item 1 of MyFormat) return " -format " & FormatCode end ChooseImageFormat on ChooseEncryption() set UseEncryption to display dialog "Do you want to encrypt this disk image?" with icon note buttons {"No", "Encrypt"} default button 1 with title MyName if button returned of UseEncryption = "No" then return "" else set KeepLooping to true repeat while KeepLooping set Password1 to text returned of (display dialog "Please enter a password to encrypt this disk image with. Your disk image will be inaccessible without this password:" buttons {"Cancel", "Set Password"} default button 2 with icon note default answer "" with title MyName with hidden answer) set Password2 to text returned of (display dialog "Please re-enter the password you have chosen:" buttons {"Cancel", "Confirm Password"} default button 2 with icon note default answer "" with title MyName with hidden answer) if Password1 ≠ Password2 then display dialog "The passwords you enetered do not match, please try again." buttons {"Cancel", "Try Again"} default button 2 with icon stop with title MyName else if (length of Password1 < 4) then display dialog "The password you selected is too short, please choose a longer one." buttons {"Cancel", "Try Again"} default button 2 with icon stop with title MyName else set KeepLooping to false end if end repeat return " -encryption AES-256 -passphrase " & quoted form of Password1 end if end ChooseEncryption on ChooseSaveFile(oldName) set OutputDMG to choose file name with prompt "Save your new Disk Image as:" default name oldName default location path to desktop return " " & quoted form of POSIX path of OutputDMG end ChooseSaveFile on RunCommand(MyCommand) with timeout of 259200 seconds set progress total steps to 1 set progress description to "Creating Disk Image" set progress additional description to "Please wait while your new disk image is created..." set progress completed steps to 1 delay 0.1 do shell script MyCommand --display dialog MyCommand set progress total steps to 0 set progress description to "Disk Image Creation Completed!" set progress additional description to "" delay 0.1 display dialog "Your disk image has been created!" buttons "OK" default button 1 with icon note with title MyName giving up after 300 end timeout end RunCommand