Skip to content

Instantly share code, notes, and snippets.

@xiian
Created July 30, 2011 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiian/1116160 to your computer and use it in GitHub Desktop.
Save xiian/1116160 to your computer and use it in GitHub Desktop.
Rename DMG files to the actual disk image name
#!/bin/bash
# Mount the disk image and parse out the output
OUTPUT=`hdid $1 | grep /Volumes | sed 's~^\([^ ]*\) .*Volumes/\(.*\)~\1 | \2~g'`
VOLNAME=`echo $OUTPUT | sed 's~^.*| ~~g'`
DEVICE=`echo $OUTPUT | sed 's~^\([^ ]*\).*~\1~g'`
# Rename the disk image
echo "Renaming $1 to $VOLNAME.dmg"
mv $1 "$VOLNAME.dmg"
# Unmount the drive
hdiutil detach $DEVICE -force -quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment