Scripts Part 5: New Spotlight Disabler

Someone recently commented that my script to disable Spotlight was no longer functioning in v. 10.4.5 of Tiger. When I went to check on the functionality of the old script, I realized I'd been working on a new and improved version awhile back, and that I'd intended to post it, but completely forgot to. So I went in and finished up this spiffy new version, and I'm posting it today for anyone who's interested, or for anyone for whom the previous version had stopped working.

This new version comes with the same disclaimers as the other one (which are now listed in the script itself), but gives you a few more options for disabling Spotlight. In particular, you can now choose to disable/enable Spotlight on either a single volume, or an all volumes. The script will also report the Spotlight status of all currently mounted volumes before asking you what you want to do.

Enjoy!

SpotlightEnableDisable Script
See the code

Scripts Part 4: Cloning — What's the Big Deal?

Boy, there sure are a lot of cloning apps out there. The mother of them all, of course, is Mike Bombich's Carbon Copy Cloner, but it's slowly losing mindshare to more aggressively marketed apps like the affable SuperDuper!. There are others, but I don't feel like scouring the web for them, nor do I feel like going to the effort of linking to them all. Suffice to say, there are plenty. Just search VersionTracker and you'll see.

I find the recent upswing in cloning utilities strange. Apple's bundled Disk Utility application has actually harbored the ability to clone a system disk for some time now (I believe as far back as Panther). And yet, it seems the easier cloning gets, the more apps there are with which to do it. And charge you for it.

Today's script uses a handy command-line utility that's actually been around since the Classic Mac OS days (though not, obviously, in command-line form): asr, which stands for Apple Software Restore. The asr command is essentially a command for cloning disks. In fact, that's exactly what it is. When Mac OS X first came out, asr was not bundled. But in recent incarnations of the OS it's hung around in the command-line, and it's actually gotten quite refined and easy to use. Want to clone your boot drive? Here's the command:

sudo asr -source [source_volume ] -target [target_volume ]

That's it. I can't imagine an easier command structure. In a way, it's almost easier to use than GUI apps that do the same thing. Of course you can get into some very complicated uses of asr, but for basic disk-to-disk cloning it's drop-dead simple.

Now there is one little, tiny bump in this road. Tiger, you see, has a brand spanking new way of making certain files on your boot drive invisible. You know, files like var and etc and private. And Tiger's version of asr (as well as Tiger's Disk Utility program) are none the wiser. So, if you want things set up properly, you need to explicitly set the visibility of these files. There are a few ways to do this. Today's script will use a utility called SetHidden, which comes on the Tiger install disc (a la this Apple KB article). Just so you know.

So here it is. A very simple script for making an exact clone of a volume to another volume. Please keep in mind, because of the file visibility issue, this script MUST be run from the disc image, or it will not work properly. Also keep in mind that cloning will overwrite, replace or even erase the target drive. I am in no way responsible for any damage you incur to your system with this script. If you don't feel comfortable using it, please don't.

That said, here's your free cloning utility.

Download ASRClone

Delayed ACK Startup Item for Intel Macs

MacFixit just reported about troubles the new Intel-based Macs are having with network speeds, particularly AFP connections to, of all things, other Macs. The solution, they report, is to set the delayed_ack property to 0. In order for this change to survive a reboot, however, they recommend editing /etc/rc. The problem with this is that, often, edits made to /etc/rc will be overwritten by future updates to Mac OSX. In my experience, such modifications are better handled with a startup item, which is also a lot easier to add and remove. So I've suggested as much to the fine folks over at MacFixit, and I've even put my money where my mouth is. I'm offering to those who need it this delayedACK Startup Item, hand made by yours truly.

The linked disc image contains the delayedACK Startup Item, and also includes an installer and an uninstaller for the Startup Item.

Enjoy, you lucky Intel Mac owners (of which, alas, I am not one... Yet...)

UPDATE:
A reader called Nubo recently left this comment:

...turning off delayed_ack is not necessarily something that should be left in the startup items forever. Having it on is normally beneficial or at least not severely degrading in normal environments. So this should be reviewed whenever Apple fixes the underlying problem in its implementation, or the actual root cause is found.

Nubo is absolutely right. This startup item should be removed — either by running the included uninstaller or by simply dragging the startup item to the trash — once the problem has been resolved by Apple.

Thanks, Nubo, for pointing this out.

Download the Delayed ACK Startup Item

Scripts Part 3: Split and Rejoin Large Files

Two events have transpired to lead to the posting of this script: 1) I've been meaning to post a new script to the Scripts section of the blog for some time, and 2) MacOSXHints today had a hint about splitting and rejoining large files, and suggesting scripting this process. I just happen to have had such a script lying around for some time, so this seemed like an especially appropriate time to post it.

Essentially, this script is made to take large files and cut them into smaller (theoretically CD or DVD sized) pieces. The same script can then be used to rejoin these chunks. For splitting, the script uses the split command, and to rejoin files, it uses the cat command.

So here it is in all its glory.

SplitAndRejoinFiles Script
See the code

Scripts Part 2: .DS_Store Remover

Why do so many Mac folk need a GUI for everything? Sometimes a little script is plenty to get the job done. And using a script can be just as easy as using a GUI: it's double-clickable; it's instructive; and it's drag-n-drop. It just doesn't have pictures. But for some reason people still freak out when they see that big, scary, text-based Terminal pop up. I used to be that way. But I've grown to love the power of the command-line, and simple shell scripts.

So here's another popular favorite: The .DS_Store Remover utility. There seem to be billions upon billions of little apps that do nothing but remove the .DS_Store files that the Mac OS puts in every folder on your system. Maybe there are so many of these little apps because it's actually such an easy thing to script. The nice thing about the script is, you can see and modify the code very simply and easily, whereas with one of these GUI wrappers, God knows what it's actually doing.

For those who don't know, the .DS_Store file holds information about how a given folder should display when it's opened. It remembers the position, size and view style (i.e. column, list or icon) of the window. Why remove them, you may ask? Some people don't like them showing up on their windows boxes, apparently. Too messy. Ahh, if only I could write a script to delete Windows boxes. That seems like the better approach.

Anyway, here's my script version. I call it "DSStoreRemover," which frankly I think is possibly the most ingenious and creative name for anything ever in the history of humans on planet Earth.

It's a really, really, drop-dead stupid simple script that takes a folder path as a variable which is used in a find command that then, in turn, executes rm on anything named ".DS_Store."

See, you don't need a GUI for this. Hell, you almost don't need a script.

.DS_StoreRemover Script
See the code