To keep some files secure on a USB thumb drive, I decided to use an Encrypted Sparse Image, which can be created in Disk Utility on Mac OS X 10.3. Unfortunately, Disk Utility does not have the ability to reclaim free space on a Sparse Image, and the Finder won't do so automatically either. So in order to be able to compact the Sparse Image and not fill up the thumb drive, I wrote this AppleScript that will compress a Sparse Image. To use this script, it needs to be saved as an application. Then just drop a Sparse Image over the application's icon and you're done.
on open this_item
set this_item to quoted form of POSIX path of this_item
do shell script "hdiutil compact " & this_item
end open
[robg adds: A previous hint provided the hdiutil command line solution; this is just a nice AppleScript wrapper for that command. If you're running a pre-10.3 system, this older hint explains how to create sparse images -- read the comments, though, as it seems the site linked in the main article has gone away, at least as of this morning when I tested it.]
•
[5,614 views]

