Skip to content

Instantly share code, notes, and snippets.

@fgarcia
Forked from aisrael/dir2dmg.sh
Created December 10, 2013 13:01
Show Gist options
  • Save fgarcia/7890232 to your computer and use it in GitHub Desktop.
Save fgarcia/7890232 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "Usage:"
echo " dir2dmg <path/to/directory>"
exit 1
fi
PWD=`pwd`
function dmg() {
dir="$1"
if [ ! -d "$dir" ]; then
echo "$dir is not a directory!"
exit 1
fi
if [ ! -r "$dir" ]; then
echo "$dir is not readable!"
exit 1
fi
vol=$( basename "$dir" )
echo "hdiutil create -volname \"$vol\" -srcfolder \"$dir\" -format UDZO \"$PWD/$vol\""
hdiutil create -volname "$vol" -srcfolder "$dir" -format UDZO "$PWD/$vol"
}
while [[ $# > 0 ]]; do
dmg "$1"
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment