Maybe somebody here has some ideas. This wasn't supposed to be difficult. The setup: my Mac is the primary place I keep my MP3s stored (~60GB at last count). I want to copy a subset to my PC laptop for use when DJing. There's no easy way for me to write down a predicate that expresses that subset, so it really needs to be done by hand. Furthermore, I have a lot of metadata like BPMs, ratings, and whatnot that's stored in the iTunes database. I want all of that to make it over to the PC.

What almost worked but didn't:

- I mounted my Mac's filesystem on the PC.
- I made a copy of the iTunes XML database and did some regexp tweaking to make all of the file names refer to the remote Mac (i.e., they now said file://localhost/Z:/Music/iTunes Music/...).
- I set iTunes to not copy files when it imports them.
- I "imported" the hacked XML file.
- 30 minutes later, I had all the data and metadata loaded, but with the files remote instead of local.
- By hand, I deleted enough entries that the files should now all fit locally.
- I asked iTunes to "consolidate" my music library.

Sadly, the consolidation only copied about 9000 out of 12000 files, saying "Copying Music failed: The file name was invalid or too long." I just tried it again, and I briefly saw the file name that made it choke:

Mary Lou Williams/Live at the Keystone Korner/02 The History of Jazz According To Mary Lou_ Spiritual III_Fandangle_Old-Fashioned Slow Blues; K.C. 12th Street; Baby Bear Boogie; attacca Roll 'Em.mp3

Is that too many characters for NTFS to deal with in a filename?

I'm assuming I'm going to have to write a Perl script to do this "consolidation" properly, since iTunes can't handle it. One issue is long filenames, possibly with special characters. Another issue is that the XML file uses web-style %-escapes (e.g., %20 for spaces), so I need to mechanically turn those back into the normal characters that are part of the file names (and, which may or may not be legal characters for NTFS). The only other issue I can imagine might haunt me is how to efficiently do the copying. The right answer seems to be gnutar's "--files-from" argument, although there is the legal file name issue to deal with.

Thoughts?