How iTunes manages media

 
This section explains how iTunes manages media.  It is very important background reading for anybody who wants to fully understand where their media is and how iTunes references it.
 

Out of the box iTunes installation

 
The diagram below shows the key elements of an iTunes installation on a desktop PC:
 
 

iTunes Library database files : iTunes Library.itl and iTunes Media.xml File

 
These two files are located under the iTunes folder within the the Music folder in your profile directory.  This means it is in one of the following two locations depending on Operating System:
 
c:\Documents and Settings\[user]My Music\iTunes (Windows XP, Windows Server 2003, WHS v1), or
c:\Users\[user]\Music\iTunes (Windows Vista, Windows 7, Windows Home Server 2011)
 
The iTunes Library.itl file is iTunes's internal database file.  This file stores a list of all the media that iTunes knows about, including playcounts, ratings, playlists plus key metadata that allows iTunes to present, sort and search for your media in different ways.  It is a binary format that is not human-readable.
 
iTunes Media.xml contains most of the same information that is found in the iTunes Library.itl file, however, is presented in somewhat human-readable XML format.  Why the two files?  iTunes originally only had the .xml file, however, in later versions migrated to the internal database format for performance reasons more than anything else.  The iTunes Media.xml was still present so that integration with third party applications that relied on this file did not break.
 
We will refer to these files at the iTunes Library database files.
 
When you add media to iTunes, either manually throught the 'File' menu, via an iHomeServer Watch Folder, or in fact most other methods, iTunes will add a reference to the full path of the file in the iTunes Library database files. 
 
If you subsequently delete or move that file manually, iTunes will not know about it and it will show up a missing media icon:
 
 
Conversely, if you add the same file through a different path (eg using a UNC path instead of a local drive path), then you may end up with duplicate media files in your iTunes library as iTunes determines uniqueness based on the full path of the file within its database.
 

iTunes Media Folder

 
The iTunes Media Folder, by default, is also within your profile's Music folder.  iTunes will store any media that it downloads in this folder.  The following are examples of media that will be stored in the iTunes Media Folder:
 
 
Additionally, if you have ticked the option within iTunes preferences to "Copy files to iTunes Media folder when adding to library" then iTunes will copy any media that has been added to iTunes either manually or via an iHomeServer Watch Folder to the iTunes Media Folder. 
 
If you have set the iTunes Preferences option "Keep iTunes Media Folder Organised" then iTunes will organise the media within your iTunes Media Folder into folders that are organed by album and artist.  It will also rename tracks with disc and track number information.
 
If you ever change the iTunes Media Folder path to move your iTunes Media folder, then all the media within the folder will, by default, stay in the old location.  Apple recommends using the "File / Library / Organize Library" menu item to move your media to the new folder - see http://support.apple.com/kb/ht1364