View Single Post
  #9  
Old 10-08-2005, 04:44 PM
edoates edoates is offline
Registered User
 
Join Date: Jul 2005
Posts: 44
Sparse image compacting automatically

I got tired of checking the size of my sparse images and manually compacting them with hdiutil. So, I added the script fragment below to the end of the "daily backup applescript" which I had already modified for my specific volumes:

tell application "Finder"
activate
eject disk "Music Backups"
end tell
activate
display dialog "Awaiting dismount of Music Backups" buttons {"OK"} giving up after 5 default button 1
-- compact the sparse image to prevent unregulated growth
do shell script "hdiutil compact " & "\"/Volumes/Eds Office Backups/Music Backups.sparseimage\""
activate
display dialog "Music Backup Complete" buttons {"OK"} giving up after 30 default button 1

The "activate" verbs cause the script to become the top application so the dialogs show up (for testing, mostly); the dialogs are all for information and time out. I wait 5 seconds for the dismount to occur: always enough time unless the volume cannot be dismounted for some reason. hdiutil will not compact a mounted sparse image.

Hope you find this useful.

Ed
Reply With Quote