|
|
Switch between two iTunes Libraries
I made an eerily similar program in AppleScript about a year ago. But instead of being run when you want to switch, it is an application that you can put in the dock instead of iTunes. When you launch it, it checks to see if the remote server is mounted, and if so, launches iTunes with that library. If the remote server is not mounted, it asks if you want to try to connect to it, or otherwise launch iTunes with the local library. That way, you don't have to keep track of whether you're toggled for remote or local, or whether you're already/still connected to the remote server or not (which is particularly useful in the case of using a remote library over a network).
Switch between two iTunes Libraries
Is there any way for you to post that script? Sounds like it's just what I'm looking for...
Switch between two iTunes Libraries
Here it is, I couldn't do the indenting, but if you copied this into AppleScript it would of course indent it for you: (* The only thing extra you need to set up for this is creating two folders in the Music folder of your client computer. (Actually you can put these folders anywhere on the client but in my code it is the Music folder.) The folders are named "iTunes Data Local" and "iTunes Data Server" in my code. Take the two library files ("iTunes 4 Music Library" and "iTunes Music Library.xml") that you currently have in the client iTunes folder and put them in the "iTunes Data Local" folder. Now mount the server and go to the equivalent place on the server where its two library files are. Make aliases to those files and put those aliases on your client where the originals were. The program will be swapping the original client settings and the aliases to the server ones, and that is basically how it works. It should be obvious which parts you need to customize but if not then let me know. *) try do shell script "top -l1 | grep -w iTunes" --Check to see if iTunes is already running on the laptop, in which case do nothing. on error tell application "Finder" set useServer to true try set localFolder to folder "iTunes" of folder "Music" of home end try try set serverFolder to folder "iTunes" of folder "Music" of disk "Server HD" --Try to make a reference to the server hard drive on error --Making the reference failed, and that means the laptop is not connected to the server yet. display dialog "Not connected to music server. Connect?" buttons {"Use Local", "OK"} default button "OK" if button returned of the result is not equal to "OK" then set useServer to false else try mount volume "afp://yourlogin@yourserver.local/server_harddrive_name" --this mounts the server drive, I don't put in the password here for security reasons, but you can put it in like this: -- afp://yourlogin:password@yourserver.local/server_harddrive_name on error display dialog "Could not connect to server." quit end try end if end try if useServer then -- Depending on what is being used, local or server set folderBeingUsed to (folder "iTunes Data Server" of folder "Music" of home) set otherFolder to (folder "iTunes Data Local" of folder "Music" of home) else set otherFolder to (folder "iTunes Data Server" of folder "Music" of home) set folderBeingUsed to (folder "iTunes Data Local" of folder "Music" of home) end if if (count of items of folderBeingUsed) is less than 1 then try --If the folder I am getting settings from is empty, that means the settings are already in the right place, so just run the program open application "iTunes" end try else --This swaps the settings that are currently there with the other ones. set theFiles to {file "iTunes 4 Music Library" of folder "iTunes" of folder "Music" of home, file "iTunes Music Library.xml" of folder "iTunes" of folder "Music" of home} move theFiles to otherFolder set theFiles to {file "iTunes 4 Music Library" of folderBeingUsed, file "iTunes Music Library.xml" of folderBeingUsed} move theFiles to folder "iTunes" of folder "Music" of home try open application "iTunes" end try end if end tell end try end if ---
Switch between two iTunes Libraries
Oh, and if you wanted this to just work for an external drive instead of on a network, you could just cut out everything after "on error" up to before the second "end try", and insert the line "set useServer to false"
Two bugs in your script...
#1: There's an extra "end if" at the end.
Switch between two iTunes Libraries
I would be really interested as well. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.11 seconds |
|