title: How to programmatically rename movie and TV show files in an iTunes library, for XBMC compatibility?
body: <p>I have a collection of movies and TV shows in iTunes, and I'd like to rename them to an <a href="http://xbmc.org/wiki/?title=TV_Shows" rel="nofollow noreferrer">XBMC compatible naming convention</a> without breaking the links in iTunes.</p>
  
  <p>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?</p>
  
  <p>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.</p>