<?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>Matejunkie &#187; gnupod</title>
	<atom:link href="http://www.matejunkie.com/tag/gnupod/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matejunkie.com</link>
	<description>"Look behind you, a Three-Headed Monkey!"</description>
	<lastBuildDate>Thu, 07 Jan 2010 14:26:10 +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>Update: How to recover mp3&#8242;s after an iPod database crash</title>
		<link>http://www.matejunkie.com/update-how-to-recover-mp3s-after-an-ipod-database-crash/</link>
		<comments>http://www.matejunkie.com/update-how-to-recover-mp3s-after-an-ipod-database-crash/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 21:11:52 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[fat32]]></category>
		<category><![CDATA[gnupod]]></category>
		<category><![CDATA[gplv2]]></category>
		<category><![CDATA[id3]]></category>
		<category><![CDATA[id3tool]]></category>
		<category><![CDATA[id3v1]]></category>
		<category><![CDATA[id3v2]]></category>
		<category><![CDATA[ipod]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[shell scripting]]></category>

		<guid isPermaLink="false">http://www.matejunkie.com/?p=812</guid>
		<description><![CDATA[I&#8217;ve recently wrote about recovering mp3&#8242;s from an iPod which expierenced a database crash after e.g. messing around with gnupod. As you may have seen the script wasn&#8217;t complete it all. It was a quick&#8217;n'dirty hack to copy all the files from a mounted iPod to a local directory where they were sorted into specific [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve <a title="Matejunkie - How to recover mp3's after an iPod database crash" href="http://www.matejunkie.com/how-to-recover-mp3s-after-an-ipod-database-crash/" target="_blank">recently wrote</a> about recovering mp3&#8242;s from an iPod which expierenced a database crash after e.g. messing around with gnupod. As you may have seen the script wasn&#8217;t complete it all.<br />
It was a quick&#8217;n'dirty hack to copy all the files from a mounted iPod to a local directory where they were sorted into specific directories depending on the artist&#8217;s and the album&#8217;s name. Furthermore, the script didn&#8217;t expand single-digit track numbers with a leading zero. That made it somewhat difficult to hear albums in the right order.</p>
<p>Therefore, I&#8217;ve decided today to expand the script a little more. Here are the details:</p>
<p>The script now works with id3v1 <strong>and id3v2</strong>. Therefore it&#8217;s necessary to have id3tool and id3v2 installed from your prefered package management system. It parses the file&#8217;s id3 tags and copies all files in a /ARTIST/ALBUM/TRACKNO-TITLE.mp3 format from the iPod to a local directory which you can specify in the second line of the actual script as the output variable. If the track number of the mp3 is single-digit, the script will expand it to a two-digit track number with a leading 0 to preserve the album&#8217;s tracklist.<br />
When it stumble upon a file without an id3 tag or a different file extension like .m4a it copies the files to the no-tags/ directory which is created in the specified output directory at the beginning of the script. Then you&#8217;ll have the chance to order them manually after running the script.</p>
<p>Grab the script from the code section below as long as I don&#8217;t provide git access (which will be available soon):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#   This program is free software; you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;">#   it under the terms of the GNU General Public License as published by</span>
<span style="color: #666666; font-style: italic;">#   the Free Software Foundation; version 2 of the License only.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;">#   but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;">#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;">#   GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   You should have received a copy of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;">#   along with this program; if not, write to the Free Software</span>
<span style="color: #666666; font-style: italic;">#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#   Author: Mike Adolphs, 2009 (http://www.matejunkie.com/)</span>
<span style="color: #666666; font-style: italic;">#   Version: 0.2, Date: 2009-03-11</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># define input/output directories</span>
<span style="color: #007800;">input</span>=<span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>ipod<span style="color: #000000; font-weight: bold;">/</span>iPod_Control<span style="color: #000000; font-weight: bold;">/</span>Music<span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #007800;">output</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>music
&nbsp;
<span style="color: #666666; font-style: italic;"># create no-id3v1 directory</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$output</span><span style="color: #000000; font-weight: bold;">/</span>no-tags
&nbsp;
<span style="color: #666666; font-style: italic;"># Let's do this...</span>
<span style="color: #007800;">files</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$input</span> <span style="color: #660033;">-type</span> f<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$files</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">v1_title</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Song Title:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Song Title:\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">v1_artist</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Artist:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Artist:\t\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">v1_album</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Album:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Album:\t\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">v1_tno</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Track:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Track:\t\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #007800;">v1_tno_length</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> length <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v1_tno</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v1_tno_length</span>&quot;</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">v1_tno</span>=<span style="color: #ff0000;">&quot;0<span style="color: #007800;">$v1_tno</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v1_title</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">v2_title</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TIT2'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TIT2 (Title/songname/content description): ##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v2_title</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #007800;">v2_title</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TT2'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TT2 (Title/songname/content description): ##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #007800;">v2_artist</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TPE1'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TPE1 (Lead performer(s)/Soloist(s)): ##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v2_artist</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #007800;">v2_artist</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TP1'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TP1 (Lead performer(s)/Soloist(s)): ##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #007800;">v2_album</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TALB'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TALB (Album/Movie/Show title): ##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v2_album</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #007800;">v2_album</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TAL'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TAL (Album/Movie/Show title): ##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #007800;">v2_tno</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TRCK'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TRCK (Track number/Position in set): ##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v2_tno</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #007800;">v2_tno</span>=<span style="color: #000000; font-weight: bold;">`</span>id3v2 <span style="color: #660033;">-l</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^TRK'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#TRK (Track number/Position in set): ##'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s#/[0-9]*##'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
        <span style="color: #007800;">v2_tno_length</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> length <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v2_tno</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v2_tno_length</span>&quot;</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #007800;">v2_tno</span>=<span style="color: #ff0000;">&quot;0<span style="color: #007800;">$v2_tno</span>&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$v2_title</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;!!! <span style="color: #007800;">$i</span> !!! --&gt; <span style="color: #007800;">$output</span>/no-tags/&quot;</span>
            <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-D</span> <span style="color: #007800;">$i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output</span>/no-tags/&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span> --&gt; <span style="color: #007800;">$output</span>/<span style="color: #007800;">$v2_artist</span>/<span style="color: #007800;">$v2_album</span>/<span style="color: #007800;">$v2_tno</span>-<span style="color: #007800;">$v2_title</span>.mp3&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-D</span> <span style="color: #007800;">$i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output</span>/<span style="color: #007800;">$v2_artist</span>/<span style="color: #007800;">$v2_album</span>/<span style="color: #007800;">$v2_tno</span>-<span style="color: #007800;">$v2_title</span>.mp3&quot;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span> --&gt; <span style="color: #007800;">$output</span>/<span style="color: #007800;">$v1_artist</span>/<span style="color: #007800;">$v1_album</span>/<span style="color: #007800;">$v1_tno</span>-<span style="color: #007800;">$v1_title</span>.mp3&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-D</span> <span style="color: #007800;">$i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output</span>/<span style="color: #007800;">$v1_artist</span>/<span style="color: #007800;">$v1_album</span>/<span style="color: #007800;">$v1_tno</span>-<span style="color: #007800;">$v1_title</span>.mp3&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<p>As always this little script is ment to be sh-compliant and released under the terms of the GPL Version 2. Please be aware of the fact, that you’ll have to install the id3tool <strong>and id3v2</strong> via your prefered package management software before running this script. Otherwise it won&#8217;t work.</p>
<p>The script will probably be enhanced in the near future with an option parser and the possibility to select between different output formats. I also think about dropping the id3tool support as id3v2 also displays id3v1 information. Let me know if you have ideas or suggestions to enhance the script further.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/update-how-to-recover-mp3s-after-an-ipod-database-crash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to recover mp3&#8242;s after an iPod database crash</title>
		<link>http://www.matejunkie.com/how-to-recover-mp3s-after-an-ipod-database-crash/</link>
		<comments>http://www.matejunkie.com/how-to-recover-mp3s-after-an-ipod-database-crash/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 18:57:06 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[fat32]]></category>
		<category><![CDATA[gnupod]]></category>
		<category><![CDATA[gplv2]]></category>
		<category><![CDATA[id3]]></category>
		<category><![CDATA[id3tool]]></category>
		<category><![CDATA[ipod]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[shell scripting]]></category>

		<guid isPermaLink="false">http://www.matejunkie.net//?p=769</guid>
		<description><![CDATA[Update: After reading this article, consider using the enhanced version of this script described in this article! As a Linux addicted nerd you often face new challenges. One challenge could be migrating an existing iTunes database to a gnupod database, just to see that the database is completely broken in the end. And if it [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;"><strong>Update:</strong></span> After reading this article, consider using the enhanced version of this script described in <a title="Matejunkie - Update: How to recover mp3's after an iPod database crash" href="http://www.matejunkie.com/update-how-to-recover-mp3s-after-an-ipod-database-crash/" target="_blank">this article</a>!</p>
<p><a href="http://www.matejunkie.com/wp-content/uploads/2009/03/id3_rename.png"><img class="size-thumbnail wp-image-773 alignleft" title="id3_rename output" src="http://www.matejunkie.com/wp-content/uploads/2009/03/id3_rename-150x150.png" alt="id3_rename output" width="150" height="150" /></a>As a Linux addicted nerd you often face new challenges. One challenge could be migrating an existing iTunes database to a gnupod database, just to see that the database is completely broken in the end. And if it doesn&#8217;t work even after a gnupod_INIT.pl -restore, you definitely want to know how to recover the 14.000 mp3&#8242;s you&#8217;ve had on your iPod.</p>
<p>So here we go:</p>
<p>On a fat32 formatted iPod all the mp3 files still remain in the following directory even after the experience of a corrupted database.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>ipod<span style="color: #000000; font-weight: bold;">/</span>iPod_Control<span style="color: #000000; font-weight: bold;">/</span>Music $ <span style="color: #7a0874; font-weight: bold;">pwd</span>
<span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>ipod<span style="color: #000000; font-weight: bold;">/</span>iPod_Control<span style="color: #000000; font-weight: bold;">/</span>Music</pre></div></div>

<p>When you take a look into the directory you&#8217;ll see different subdirectories with the following naming convention and your actual mp3 files inside these directories.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>ipod<span style="color: #000000; font-weight: bold;">/</span>iPod_Control<span style="color: #000000; font-weight: bold;">/</span>Music $ <span style="color: #c20cb9; font-weight: bold;">ls</span>
f00  f02  f04  f06  f08  f10  f12  f14  f16  f18  f20  f22  f24  f26  f28  f30  f32  f34  f36  f38  f40  f42  f44  f46  f48
f01  f03  f05  f07  f09  f11  f13  f15  f17  f19  f21  f23  f25  f27  f29  f31  f33  f35  f37  f39  f41  f43  f45  f47  f49
user<span style="color: #000000; font-weight: bold;">@</span>host <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>ipod<span style="color: #000000; font-weight: bold;">/</span>iPod_Control<span style="color: #000000; font-weight: bold;">/</span>Music $ <span style="color: #c20cb9; font-weight: bold;">ls</span> f00<span style="color: #000000; font-weight: bold;">/</span>kpod0006400.mp3f00
<span style="color: #000000; font-weight: bold;">/</span>kpod0006400.mp3</pre></div></div>

<p>To recover your files in a proper naming convention like &#8220;ARTIST/ALBUM/TRACK_NO.-TITLE.mp3&#8243; you may want to grab the following shell script I&#8217;ve &#8220;quick&#8217;n'dirty-written&#8221; for this purpose. It&#8217;ll read files recursive from an input directory, get&#8217;s the id3v1 information from your mp3 files and copies them to an output directory. The input and output directory has to be defined by yourself in line 4 and 5. All files without an id3v1 tag will be copied to a subdirectory called no-id3v1 and therefore need manual care to refit them into your music library.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># define input/output directories</span>
<span style="color: #007800;">input</span>=<span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>ipod<span style="color: #000000; font-weight: bold;">/</span>iPod_Control<span style="color: #000000; font-weight: bold;">/</span>Music<span style="color: #000000; font-weight: bold;">/</span>f<span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #007800;">output</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>music<span style="color: #000000; font-weight: bold;">/</span>output
&nbsp;
<span style="color: #666666; font-style: italic;"># create no-id3v1 directory</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$output</span><span style="color: #000000; font-weight: bold;">/</span>no-id3v1<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Let's do this...</span>
<span style="color: #007800;">files</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$input</span> <span style="color: #660033;">-type</span> f<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$files</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">title</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Song Title:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Song Title:\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">artist</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Artist:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Artist:\t\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">album</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Album:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Album:\t\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tno</span>=<span style="color: #000000; font-weight: bold;">`</span>id3tool <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'^Track:'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/Track:\t\t//'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[ \t]*$//'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$title</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;!!! <span style="color: #007800;">$i</span> !!! --&gt; <span style="color: #007800;">$output</span>/no-id3v1/<span style="color: #007800;">$i</span>&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-D</span> <span style="color: #007800;">$i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output</span>/no-id3v1/&quot;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$i</span> --&gt; <span style="color: #007800;">$output</span>/<span style="color: #007800;">$artist</span>/<span style="color: #007800;">$album</span><span style="color: #007800;">$tno</span>-<span style="color: #007800;">$title</span>.mp3&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">-D</span> <span style="color: #007800;">$i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$output</span>/<span style="color: #007800;">$artist</span>/<span style="color: #007800;">$album</span>/<span style="color: #007800;">$tno</span>-<span style="color: #007800;">$title</span>.mp3&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<p>As always this small code snippet is ment to be sh-compliant and released under the terms of the GPL Version 2. Please be aware of the fact, that you&#8217;ll have to install the id3tool via your prefered package management software before running this script.<br />
I&#8217;ll probably enhance the script so that it can be configured via an option parser, working with id3v2 information and different output formats as well. I&#8217;ll let you know when it&#8217;s finished.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/how-to-recover-mp3s-after-an-ipod-database-crash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
