I made an application that parse the iTunes library to retrieve its content. It works fine in most cases but if a user moved his library somewhere else than the default iTunes folder (see: http://lifehacker.com/238296/ultranewb--how-to-move-your-itunes-library-to-an-external-drive), then I need a way to find this path.
On Mac, I was looking into ~/Library/Preferences/com.apple.iTunes.plist. There is a setting called "alis:1:iTunes Library Location" but it contains several parameters all concatenated and converted to hexadecimal.
On Windows, I found this file "C:\Documents and Settings\\Application Data\Apple Computer\iTunes\iTunesPrefs.xml" that contains a setting "iTunes Library XML Location:1" but this one is encoded.
Any help would be greatly appreciated. Thanks!
After you turn on Sync Library on your Mac, PC, iPhone, or iPad, you can access your music library on any device that has the Apple Music app. Just make sure that your device is signed in with the same Apple ID that you use with your Apple Music subscription. You can also access your music library on music.apple.com.
Hold down the Option key on a Mac or the Shift key on Windows and launch iTunes. Hold down that key until a window pops up asking you to Choose iTunes Library. Click Choose Library. Navigate through your computer to find the external hard drive.
Make sure all of your devices have Sync Library turned on and signed in with the same Apple ID that you use with Apple Music. If your music library is stored on your computer, check the cloud status of songs to find missing music and resolve issues.
On Windows, the iTunes Library XML Location:1
entry in iTunesPrefs.xml
is a Base 64 encoded Unicode string, so you'll need to decode it before you can use it. On my PC, it decodes to C:\Documents and Settings\Emerick\My Documents\My Music\iTunes\iTunes Music Library.xml
.
It should be relatively easy to decode this value using your language of choice; your platform may even provide utility libraries that make this trivial. In C#, for example, the decoding function would look something like this:
static public string DecodeBase64(string encodedData)
{
byte[] encodedBytes = System.Convert.FromBase64String(encodedData);
return System.Text.UnicodeEncoding.Unicode.GetString(encodedBytes);
}
I can't help you with the Windows stuff, but on the Mac what you're seeing in that prefs file is old-school alias handle data. Take a look at or just use Chris Hanson's BDAlias class to convert it to a path.
http://github.com/rentzsch/bdalias
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With