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


Click here to return to the 'Make a .dmg from any directory' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Make a .dmg from any directory
Authored by: omnivector on May 12, '04 09:56:23PM
here's an even simpler and more safe script:
#!/usr/bin/env ruby

# usage error
if ARGV.length < 1 or ARGV.length > 2 then
    $stderr.puts( "Usage: #{File.basename( $0 )} directory [cd name]" )
    exit( 1 )
end

# get variables
dir = ARGV.shift.sub( /\/$/, "" )
volname = if ARGV.length == 0 then
        File.basename( File.expand_path( dir ) )
    else
        ARGV.shift
    end
output = "#{dir}.dmg"

# dmg the folder
`hdiutil create -fs HFS+ -srcfolder "#{dir}" -volname "#{volname}" "#{output}"`

---
- Tristan

[ Reply to This | # ]

Make a .dmg from any directory
Authored by: ov on Nov 05, '04 05:23:21PM

And here is an AppleScript version,
Just copy paste the following text into "Script Editor" and save it as an application
this script is a droplet, you only have to drop a folder onto the applescript application icon

[code]
on open (list_of_aliases)
set itemStr to (first item of list_of_aliases) as string
if (itemStr ends with ":") then
-- removes the ending ":" character
set itemStr to characters 1 through ((length of itemStr) - 1) of itemStr as string
createDMG(itemStr)
else
display dialog "The dropped element must be a folder and not a file" buttons {"Exit"} default button "Exit"
end if
end open

on createDMG(x)
set srcName to (POSIX path of x)
set targetName to srcName & ".dmg"
set srcName to quoted form of srcName
set targetName to quoted form of targetName

set scriptStr to "hdiutil create -fs HFS+ -srcFolder " & srcName & " " & targetName & " 2>&1 &"
say "Creating disk image from folder " & srcName
say "Please be patient ..."
display dialog "Please be patient ..." giving up after 2
do shell script scriptStr
set res to the result
display dialog res
end createDMG

[/code]


Regards
Olivier



[ Reply to This | # ]
Make a .dmg from any directory
Authored by: sbussard on Jan 02, '08 10:58:13PM

Tristan it might be easier to use if the path is absolute and not relative.

Good interpretation of what the script should be though, now all that is needed is a simple GUI ;)



[ Reply to This | # ]