iTunes Artwork Folder Structure

With the weather and dark nights forcing me out of the garden, I have recently turned my attention to sorting out my media library, working towards a music streaming solution throughout the house. This starts with getting my iTunes library in order.

One of the problems for me with iTunes is the way it stores artwork. All the tracks are stored in their folders, but iTunes will use a sneaky way of hiding the artwork into an *.itc file which is then hidden away in a confusing folder structure, thus stopping other programs from accessing it.

After finding this post¬†decyphering the location of the artwork file, I wrote a Java function to take a track’s persistent ID and return the location of the artwork, if it existed. Here is the code.

public static File getArtwork(String libId, String trackId) {
		File artwork = null;

		// Get the last three characters from the tracks ID and turn them into
		// decimals, with a leading zero if needed.
		String folderOne = hexToDec(trackId.charAt(trackId.length() - 1));
		String folderTwo = hexToDec(trackId.charAt(trackId.length() - 2));
		String folderThree = hexToDec(trackId.charAt(trackId.length() - 3));

		// artwork can be stored in itc or itc2 files, so we should check if the
		// itc exists, and if not, try the itc2.
		artwork = new File("Album Artwork/Download/" + libId + "/" + folderOne
				+ "/" + folderTwo + "/" + folderThree + "/" + libId + "-"
				+ trackId + ".itc");
		 * Note: the Downloads folder is the best place to look. If the artwork
		 * is in the Cache folder, then I think that means the track already had
		 * artwork embedded in the MP3 so it wasn't downloaded, just cached for
		 * faster access by iTunes.
		return artwork;

	private static String hexToDec(char hexValue) {
		switch (hexValue) {
		case '0':
			return "00";
		case '1':
			return "01";
		case '2':
			return "02";
		case '3':
			return "03";
		case '4':
			return "04";
		case '5':
			return "05";
		case '6':
			return "06";
		case '7':
			return "07";
		case '8':
			return "08";
		case '9':
			return "09";
		case 'A':
			return "10";
		case 'B':
			return "11";
		case 'C':
			return "12";
		case 'D':
			return "13";
		case 'E':
			return "14";
		case 'F':
			return "15";
			return "";

I am basically using this to parse an XML file, find any artwork which isn’t embedded into the MP3 file and then save it inside, so that all my other media players have access to the image. It will increase the file size a little, but for me that’s negligible. I suppose someone could also use it to store the artwork in an understandable structure (ArtistName/AlbumName) so that it could be retrieved that way, but that can be looked at later.