Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

harleytat

macrumors newbie
Original poster
Jul 22, 2002
23
4
I have a Drobo to which I backup five drives using SuperDuper as sparsebundles. I also regularly compact the sparsebundles using a simple Applescript that looks like this:

Code:
do shell script "hdiutil compact /Volumes/Drobo/'Drive 1.sparsebundle'"

do shell script "hdiutil compact /Volumes/Drobo/'Drive 2.sparsebundle'"

etc...

However, I'd rather use grep/wildcards to compact EVERY sparsebundle on my Drobo, as I sometimes temporarily backup client drives to the Drobo as well. When I do "hdiutil compact /Volumes/Drobo/*.sparsebundle," the compact fails, as the terminal is trying to compact all of them simultaneously (which makes sense).

My question: Is it possible to write a single terminal command that sequentially compacts all sparsebundles on a drive?
 
My question: Is it possible to write a single terminal command that sequentially compacts all sparsebundles on a drive?

Yes.








Oh, so you wanted a hint rather than the direct question answered? A combination if ls, xargs and your hdiutil command should do it.
 
Thanks, Robbie, for the clue--but I'll take the full answer if you got it! :)
 
Thanks, Robbie, for the clue--but I'll take the full answer if you got it! :)

Well as I don't have a similar environment to test your code in this is just typed straight into the reply box: it might well not work.

Code:
ls -1 /Volumes/Drobo/*.sparsebundle | xargs -IREP hdiutil compact /Volumes/Drobo/REP
 
And this might work, too:

Code:
set bundleList to list files of "/Volumes/Drobo/"

repeat with bl in bundleList
	
	do shell script "hdiutil compact /Volumes/Drobo/" & (quoted form of (bl as string))
	
end repeat

mt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.