Created
April 4, 2013 07:13
-
-
Save aisrael/5308455 to your computer and use it in GitHub Desktop.
dir2dmg.sh—a bash script to create OS X .DMG images from the given folder or folders (supports wildcards).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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