dougscripts.com

May 31 2015 - 10:42 am

Check For Library Corruption With xmllint

A Correspondent recently reported that a script which needed to read the current "iTunes Library.xml" file was failing. This XML file, as you may know, is exported periodically by iTunes and is pretty much an abridged output of the actual iTunes database. Even the XML file exported by iTunes' File > Library > Export Library... command was unable to be read. This suggested that there might be some corruption in the track entries, (I recently had a similar report and that database contained corruption that prevented the XML from being exported; the user reported that the XML had last been updated in 2012.)

iTunes can seem to behave normally even if there are tracks with corrupted track entry data or corrupted metadata in their files. So you might not even be aware of corruption until a third-party appliance elicits errors.

There is a command-line tool called xmllint that can find some corruption in the "iTunes Library.xml". You can run it from Terminal, or in a script like this:

set f to choose file

set rez to (do shell script "xmllint --valid --noout " & quoted form of POSIX path of (f as text))

This will error when it finds some badly encoded or improper UTF-8 text, which is often the culprit. Then it's just a matter of finding the troublesome tracks in iTunes and fixing the problems if possible. Usually this means just editing the tags in iTunes.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.