I have a collection of movies and TV shows in iTunes, and I'd like to rename them to an XBMC compatible naming convention without breaking the links in iTunes.
All the necessary metadata (season number, show name, episode number, etc) seems to be in an XML file that iTunes manages, and the episode name is the current file name. So programmatically renaming the files seems fairly straightforward but how do I keep the iTunes library straight at the same time? Is it enough to rewrite the XML file to point to the new file names?
I'd rather not get into applescript if I can avoid it (life is too short), however if it is easier to do it that way I may look at it. Otherwise I'd ideally like to do this in ruby.
On Windows Apple provides the iTunes COM for Windows SDK that works quite well. It is created using a COM interface so it works with almost every language available for Windows. It provides methods for renaming Tracks and Playlists. I have used this to do all kinds of things with my Library.
I do not know what's available on a MAC, but I believe AppleScript is the best native way to access what's available. There is a project called "EyeTunes" that provides a Cocoa framework. There is a site devoted to Applescript ("Doug's AppleScripts for iTunes"). Here is a site showing how to access iTunes from perl.
If you want to rename both the file and the iTunes name then it's probably better to change the track name, remove the file from the library, rename the file, and then re-add the track. You would need to preserve information like last played, playcount, etc.