Created
March 9, 2014 16:59
-
-
Save wolph/9450781 to your computer and use it in GitHub Desktop.
Script to automatically convert directories to sparse images on OS X. Since I have noticed a pretty obvious slowdown in OS X when having lots (many millions) of files on the filesystem, this has given me quite a significant speedup.
This file contains 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 -e | |
function image_all(){ | |
echo "Processing $1" | |
test -d "$1" || return 1 | |
cd "$1" | |
for i in *; do | |
if [ "$i" == "utils" ]; then | |
continue | |
fi | |
image="$i.sparseimage" | |
if [ -d "$i" ] && [ ! -f "$image" ]; then | |
echo "Creating $image from $i" | |
hdiutil create -size 1G -format UDSP -srcfolder "$i" -volname "$i" "$i" | |
echo "Removing $i" | |
rm -rf "$i" | |
else | |
echo "Skipping $i" | |
fi | |
done | |
} | |
image_all ~/workspace/ | |
image_all ~/envs/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment