NEW: Launch at Login v1.0
It is often convenient and desirable to have your designated iTunes Media folder—the folder pointed to in the “Advanced” tab of iTunes’ Preferences—located on a large external drive or server. Those of you who do this know the advantages.
An issue that has been known to occur with this configuration is that if the volume or server containing the designated iTunes Media folder does not mount during the computer’s startup before iTunes launches, iTunes will presume that this folder is inaccessible and it will default to using the ~/Music/iTunes/iTunes Media/ folder instead. It does this because it needs a definitive place in which to save CD rips (which still happen at my house), converted files and Store purchases.
(More modern versions of iTunes are much better at reverting to the designated iTunes Media folder if its volume is mounted later. But for years this was always dicey and still can be.)
This swapping of designated iTunes Media folders can be problematic. It can render tracks in the iTunes library dead, duplicated, missing, orphaned. And so on.
My podcast partner, Kirk McElhearn, and I discuss this issue on an upcoming episode of The Next Track podcast concerning using a network-attached storage device (NAS) to store iTunes media. In conjunction with that episode, I wrote a script applet to be used as a “Login Item”, Launch at Login, that will attempt to mount the volume at startup, confirm it is actually mounted and only then launch iTunes.
Typically, AppleScript can use the mount volume command, which under some circumstances requires providing a username and password. I didn’t want to do that because 1) it is difficult for AppleScript to securely manage storing that data and 2) it is awkward having users edit the script to “hard-code” their username and password. But this script avoids having to do that—and not in any devious way—by attempting to open a folder on the volume pointed to by an alias to it in a specific local folder on the startup drive. In order to open this alias’d folder the operating system will be obliged to mount the volume/server it is on; the script will wait until that folder is accessible and then will launch iTunes. If, for some reason, the folder does not become accessible within a reasonable amount of time because the volume didn’t mount, the script will not launch iTunes and will display an alert saying so. At that point the user can decide what to do; presumably, mount the server and then launch iTunes manually.
The anxious part of me feels obliged to note that this script does not use any security (other than being signed with my Developer ID) so if you do not want a volume or server to be mounted in unattended startup situations then do not use it.
There are some simple yet specific instructions and caveats to heed before using the script at your house so be sure to read the documentation that accompanies the script in the download. More information about the Launch at Login applet and download is on this page.