Skip to content

Instantly share code, notes, and snippets.

@ptone
Created September 14, 2010 21:20
Show Gist options
  • Save ptone/579793 to your computer and use it in GitHub Desktop.
Save ptone/579793 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
FOLDER="$1"
echo $FOLDER
if [ -z "$FOLDER" ]; then
echo
echo "usage: $0 <folder>"
echo
exit 1
fi
if [ ! -d "$FOLDER" ]; then
echo $FOLDER does not exist
exit 2
fi
UserName=`basename "$FOLDER"`
Output="/Volumes/data/oldusers/$UserName.dmg"
echo clearing
rm -r "$FOLDER/Library/Caches"
rm -r "$FOLDER/.Trash"
rm -r "$FOLDER/.Spotlight-V100"
if [ -d "$FOLDER/Music" ]; then
rm -r "$FOLDER/Music"
fi
# echo changing-perms
# echo `chown -R x1admin "$FOLDER"`
#move out the iPhoto
if [ -d "$FOLDER/Pictures/iPhoto Library" ]; then
mv "$FOLDER/Pictures/iPhoto Library/" /Volumes/data/iphotos/$UserName
fi
echo creating-dmg
echo `hdiutil create -fs HFS+ -srcfolder "$FOLDER" -volname "$UserName" "$Output"`
echo deleting
rm -r "$FOLDER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment