Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Relocation of a non-standard iTunes library structure Apps
Since I have a lot of automatic playlists based on play count, not losing the play count data was decisive when I had to move my iTunes library from a workstation to a server. However, if you just move the folder and export/import the iTunes library, exactly one thing is lost -- the play count. The way to keep the play count intact is to first change the location of the iTunes libary in your prefs, and then use the Advanced -> Consolidate Library menu option. However, this method requires that you have organized your music the way Apple suggests.

For me, the Apple way of organizing my music is not flexible enough. In my music folder, I have a few subfolders, e.g., My albums, Demos, Bootlegs etc. The reason for this is that I want to apply different sharing restrictions on each directory. For example, the "My albums" folder everyone on the computer may read, the "Demo" folder is OK to share on Gnutella or DC, but no one but me must be allowed to listen to my bootlegs. The folders are organized like this:
Music
  My albums (below I will refer to this level as the root)
    Name of artist/composer
      Album name
        01. Trackname.mp3
        02. Trackname.mp3
I handle compilations slightly different, I have a separate folder for them named Compilations:
Music 
  My albums 
    Compilation 
      Album name 
      01. Artistname - Trackname.mp3 
      02. Artistname - Trackname.mp3 
In the compilations case, I do not think it makes sense to have a a lot of artist folders with only one track in them. I typically have a lot of compilations from independent record companies with a lot of bands that never released more than an occasional track or two.

The big questions now is how to migrate this setup and keep the play count. I found a way that worked to about the 95% level (see caveats at the end about the missing 5%). Read the rest of the hint for all the details on how I accomplished this...

First one has to be aware of how iTunes traces the tracks in its library. By experimenting a little, I found that first it looks for inodes and as fallback if the inode is not availble, it looks for the file's path. I don't know if there are any further fallbacks.

Secondly, one also has to be aware of what iTunes does when it consolidates the library: when consolidating the library, iTunes looks at the ID3 tags of all tracks in its library it can find, and creates a hierarchy like this:
Music
  Name of artist/composer
    Album name 
      01. Trackname.mp3
      02. Trackname.mp3
  Unknown artist [for tracks without ID3-tags]
    Unknown album
      Trackname.mp3
      Trackname.mp3
Please note that the "My albums" level is removed. In addition, iTunes leaves the name of the tracks untouched. Simply consolidating the libary would, in my case, therefore have caused an unacceptable result, since the first level of separation ("My albums," "Demos," "Bootlegs" and a few more) would have disappeared.

The solution was to consolidate one root level ("My albums") folder at a time. However, it was not that easy. I realized this after my first attempt, when I simply moved the other root level folders to another location on the same partition. iTunes still kept track of the files in these folders, due to their inodes, and therefore, consolidated them toghether with the "My albums" folders.

To force iTunes to temporarily forget about the files in the other root folders, I had to duplicate them, and delete the original folder. Now I had something that looked like this:
Music
  My albums
  Demos (copy)
  Bootlegs (copy)
Consolidating now leads to only the "My albums" folder being consolidated. Obviously, you have to re-create the hierarchy on the receiving computer and volume. That is, when you changed the path to the iTunes library, you cannot change to "/Another volume/Music" when you consolidate the "My albums" root folder. Rather, you have to point it to "/Another volume/Music/My albums."

After consolidating "My albums," I duplicated this directory on the original volume and deleted the the original folder to be sure that the inode number changed. You should not need to do this, but I was so annoyed after working with this for a week so I felt "better safe than sorry." However, what you need to do is duplicate the "My albums" folder and then delete the original folder in its new location to break the inode connection. The folder hierarchy must look something like this after consolidating the "My albums" folder and preparing to consolidate the "Demos" folder:
[old location]
Music
  My albums (copy) [the probably not necessary step]
  Demos [rename it back to its original name so iTunes' paths works]
  Bootlegs (copy)
[new location]
Music
  My albums (copy) [to break the inodes]
  Demos [an empty folder to which you point iTunes library prefs]
Now iTunes finds everything in the "Demos" folder and has lost track of the "My albums" folder (both on the original and the new location). iTunes also has lost track of the "Bootlegs" folder in the original location. To distill this process:
  1. Duplicate all root level folders in your original location (to break inodes). Rename the one you will consolidate back to its original name (to make iTunes 'soft links' to its files work).
  2. Create a folder in your Music folder on the new location with the same name as the folder you are consolidating (i.e. My albums)
  3. Change iTunes prefs to point to the folder you created in step 2.
  4. Consolidate library. If this was the last root folder you want to consolidate, break here and go to step 8.
  5. Duplicate the consolidated folders, both on the original and new location (to break inodes). Delete original folders.
  6. On the original location, rename the next folder you will consolidate to its original name (by removing " (copy)" at the end of the folder's name; this enables the soft links).
  7. Repeat from step 2 with all folders.
  8. You now have a hierarchy like this on the new location:
    Music
      My albums (copy)
      Demos (copy)
      Bootlegs
  9. Quit iTunes and remove " (copy)" from all folders names.
Start iTunes and see that all warnings about missing songs are gone. To be completely sure that the consolidation really worked, you can quit iTunes again and unmount the volume with the original Music folder on it, and then start iTunes again. To find any missing tracks, you use a script, e.g., List MIA:s which you can find on malcolmadams.com/itunes/

Caveats:
  1. My compilation directory was destroyed; now I have a lot of folders with only one or two songs in them. I would appreciate suggestions on how to fix this.
  2. I think this method is a PITA; really, there should be an easier way. Basically you only need to change the prefix in the search path in iTunes' library, something like replacing the string "/Volumes/Old location/Music/" with "/Volumes/New location/Music/" on every entry in the iTunes track database
Now I only miss one feature in iTunes -- improved intelligent playlists that lets you create playlists with the 25 most played songs minus the ten most played songs. This way your playlist would automatically compensate with new songs rather than today's situation where most played playlists just increse the tendency of a track being played frequently, which leads to a situation where you get bored of the music. Any takers?
    •    
  • Currently 2.00 / 5
  You rated: 1 / 5 (4 votes cast)
 
[43,288 views]  

Relocation of a non-standard iTunes library structure | 11 comments | Create New Account
Click here to return to the 'Relocation of a non-standard iTunes library structure' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Relocation of a non-standard iTunes library structure
Authored by: DougAdams on Apr 23, '03 11:07:16AM
Here is the direct link to List MIAs, mentioned above.

Doug
Doug's AppleScripts for iTunes

---



[ Reply to This | # ]

Relocation of a non-standard iTunes library structure
Authored by: grrr223 on Apr 23, '03 11:55:19AM

I don't know how useful this would be while moving your links,
but if you let iTunes organize your music library (I understand in
your case this may not be as useful), if you click "part of
compilation" in a songs get info window, then it organizes the
album the way you want it to. Instead of putting each song in
it's own artist folder with one song in it, there is a folder at the
artist level of the iTunes music folder called "compilations" and
then there is a folder in there for each album, regardless of the
multiple artists present.



[ Reply to This | # ]
Relocation of a non-standard iTunes library structure
Authored by: crazyj on Apr 23, '03 02:47:51PM
...I have a lot of folders with only one or two songs in them. I would appreciate suggestions on how to fix this.

Highlight all the tracks in compilations, Get Info (Cmd-I), and check the box next to "Part of a Compilation." iTunes will now create a folder named "Compilations" with sub-folders for each album title.

---

--

Pixel Pimp, MacSlash

www.MacSlash.com

[ Reply to This | # ]

Relocation of a non-standard iTunes library structure
Authored by: david-bo on Apr 23, '03 04:12:48PM

The problem with this method is that for it to work I need to enable 'Keep library organized'. I cannot do that because I need the higher flexibility in sorting my music I described in the hint.

---
http://www.google.com/search?as_q=%22Authored+by%3A+david-bo%22&num=10&hl=en&ie=ISO-8859-1&btnG=



[ Reply to This | # ]
Relocation of a non-standard iTunes library structure
Authored by: DeltaTee on Apr 28, '03 01:09:55PM
Keep looking on Doug's Site until you run across my script Organize Files, which will let you put everything back into proper order.

[ Reply to This | # ]
Relocation of a non-standard iTunes library structure
Authored by: Graff on Apr 23, '03 06:49:22PM
It sounds like this would be a good job for using aliases. If the only reason you are keeping your files apart is to know what to share and what not to share, can't you just make 3 folders full of aliases to the files. Each would have aliases to the various music files. You could then allow iTunes to manage your music library all it wants and you would never have to worry about it. If you wanted to share a certain type of file, just share the folder full of the proper aliases.

The only trouble might be when you add a new song to iTunes, but that can be handled via a simple script to add an alias to the proper folder. Here's a sample script. Enter it into Script Editor, make a folder to hold the aliases, change the target_folder variable to the path of this folder, and save it with an appropriate name in "~/Library/iTunes/Scripts/". Then just select the tracks you want to file an alias to and select this script from the Script menu in iTunes. You can repeat the process with as many categories as you want, just make another folder and another script, changing the appropriate bits.

-----------

set the target_folder to "Path:To:Your:Folder:"

tell application "iTunes"
	set these_tracks to the selection of browser window 1
	if these_tracks is {} then error "No tracks are selected in the front window."
	
	set these_files to {}
	repeat with i from 1 to the count of these_tracks
		set the end of these_files to (the location of item i of these_tracks)
	end repeat
end tell

tell application "Finder"
	activate
	set the copy_counter to 0
	repeat with i from 1 to the count of these_files
		set the replace_flag to true
		set this_file to (item i of these_files) as alias
		set this_name to the name of this_file
		if (exists file this_name of folder target_folder) then
			display dialog ("The file "" & this_name & 
				"" already exists in the chosen folder." & 
				return & return & "Should it be replaced?") 
				buttons {"Cancel", "Skip", "Replace"} default button 3
			if the button returned of the result is "Skip" then
				set the replace_flag to false
			end if
		end if
		if the replace_flag is true then
			make new alias file at folder target_folder to this_file with replacing
			set the copy_counter to the copy_counter + 1
		end if
	end repeat
end tell

tell application "iTunes" to activate


[ Reply to This | # ]
Intelligent Playlists
Authored by: swa on Aug 12, '05 11:15:32AM

At the end of this article you ask for intelligent playlists that give you (25 most frequently played tracks) minus (10 most frequently played tracks). Well, this can be done rather easily if you set up two auxiliary playlists "MF25" and "MF10" as described and then make a third playlist "MF25-10" with two criteria: "playlist is MF25" and "playlist is not MF10".

However, this is probably still not what you expected: Assuming that you play these songs from "MF25-10" a lot, no new songs will ever enter into "MF25".

I would rather suggest that you
1) define a set of interesting songs, e.g. based on their rating and
2) sort them by least frequently played first.
Thus, you would cover all "interesting" songs and always listen to "new" songs.

If this is still not what you want (never play your favorite songs but always new songs) you might also combine the two approaches:

Let's assume you defined the "LF15" playlist to contain the 25 least frequently played interesting songs. You can then define a "MIX40" playlist as "playlist is MF25-10" or "playlist is LF25".

As you can see, there is almost no end to what you can do by combining auxiliary playlists with rather simple and straightforward logic.

Hope that helps,
Stephan



[ Reply to This | # ]
Preserving play data
Authored by: Schmolle on Nov 18, '05 04:48:03AM

Or ... you can circumvent all that iTunes pretends to know about your disk(s) and do the following:

  1. Shut down iTunes
  2. empty the 'iTunes Library' file
  3. modify the 'iTunes Library.xml' file as per your moved files
  4. Start up iTunes.

iTunes (on Windows, at least; can't say that I have tested on Mac) recognises that something Bad(tm) has happened and makes a very good attempt at restoring the database file from it's XML counterpart.

Full instructions (sadly Windows-centric) on this page.

hth

[ Reply to This | # ]
Preserving play data
Authored by: vikash on Mar 04, '06 11:16:53AM

This seemed to work on my Mac. Thanks.



[ Reply to This | # ]
Relocation of iTunes library preserving structure, ratings
Authored by: rnh on Nov 25, '05 07:48:46PM

Now your suggestion under Caveat 2 works.

iTunes 6.0.1 saves all this information in the xml version of your library. After quitting iTunes, I moved my music around (to a different partition), edited the xml file to indicate the new location, saved this new version on my Desktop, deleted the library data base and xml file from the iTunes folder, restarted iTunes and imported the recently edited xml file.

CAUTION: don't save the edited xml in the iTunes folder!

It wasn't mentioned but if you are just moving your music around on a single volume, skip all this, just drag things around with the finder.



[ Reply to This | # ]
Relocation of iTunes library preserving structure, ratings
Authored by: Link33 on Feb 24, '06 11:37:51AM

I know this thread is getting old. I found this solution to be the easiest way to go short of consolidating the library. (iTunes froze when I consolidated--not a beach ball freeze--a full out mouse only working system freeze.)
I used TextEdit to do the find and replace, and then the Import. Took a little while but very nicely updated my library.
Thanks a million!



[ Reply to This | # ]