<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Casper Kuijjer's Homepage &#187; shell</title>
	<atom:link href="http://www.kuijjer.com/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kuijjer.com</link>
	<description></description>
	<lastBuildDate>Wed, 31 Mar 2010 19:52:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Restoring a corrupt iTunes library</title>
		<link>http://www.kuijjer.com/2009/02/restoring-a-corrupt-itunes-library/</link>
		<comments>http://www.kuijjer.com/2009/02/restoring-a-corrupt-itunes-library/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 20:12:05 +0000</pubDate>
		<dc:creator>ckuijjer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.kuijjer.com/?p=51</guid>
		<description><![CDATA[After inserting an external hard drive yesterday, my iTunes library became corrupt. It apparently saw the external hard drive as the location of my music, something for which I indeed used the drive eons ago. After disconnecting the drive I noticed that some newly added songs would not sync to my iPhone. I reconnected the [...]]]></description>
			<content:encoded><![CDATA[<p>After inserting an external hard drive yesterday, my iTunes library became corrupt. It apparently saw the external hard drive as the location of my music, something for which I indeed used the drive eons ago.</p>

<p>After disconnecting the drive I noticed that some newly added songs would not sync to my iPhone. I reconnected the external drive, checked the location of my music (which as I later found out is only updated after relaunching iTunes) and used the _File > Library > Consolidate _ . When I noticed that it was copying all my music to instead of from the external drive I canceled the process. And so I ended up with an iTunes library that thinks that my music is split between two disks even when all the music is still available in its original location.</p>

<p>I&#8217;ve quit iTunes and tried to fix iTunes library. iTunes keeps its music library in the file <strong>~/Music/iTunes/iTunes Library</strong> and also exports it the XML file <strong>~/Music/iTunes/iTunes Music Library.xml</strong>. iTunes directly uses <strong>~/Music/iTunes/iTunes Library</strong> and will only reconstruct it from the XML file when this file is corrupt (if it&#8217;s simply deleted iTunes will start with an empty library).</p>

<p>First I&#8217;ve made a backup of ~/Music as these steps might make the problem even worse.</p>

<pre><code>mv ~/Music/iTunes Music Library.xml ~/Music/iTunes Music Library.xml.backup
</code></pre>

<p>Corrupt the database by replacing it with some data, I suggest</p>

<pre><code>echo 'stupid iTunes' &gt; ~/Music/iTunes Library
</code></pre>

<p>Then replace all occurrences to the external hard drive with the original location. In my case the external hard drive lives at <strong>/Volumes/Music/Music</strong> and the original location was <strong>/Users/ckuijjer/Music</strong></p>

<pre><code>perl -pe 's@Volumes/Music@Users/ckuijjer@g' ~/Music/iTunes Music Library.xml.backup &gt; ~/Music/iTunes Music Library.xml
</code></pre>

<p>Start iTunes and wait for it to import the XML file</p>

<p>Now lets see if all my iPhone applications are still there and that it still syncs with my iPhone. Also updating Time Machine as I had it configured to skip <strong>~/Music</strong>. Changing that to skip <strong>~/Music/iTunes/iTunes Music</strong>, e.g. skip the music files itself, but please, please backup iTunes library.</p>
 <img src="http://www.kuijjer.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=51" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://www.kuijjer.com/2009/02/restoring-a-corrupt-itunes-library/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
