Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find iTunes library folder on Mac and Windows?

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!

like image 431
Boris Avatar asked Dec 26 '09 01:12

Boris


People also ask

How do I access Apple Music library on Windows?

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.

How do I find my iTunes library on an external hard drive?

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.

Why isn't my iTunes library showing up on my new computer?

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.


2 Answers

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);
}
like image 74
Emerick Rogul Avatar answered Sep 19 '22 05:09

Emerick Rogul


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

like image 22
Ken Aspeslagh Avatar answered Sep 22 '22 05:09

Ken Aspeslagh