<?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; id3v2</title>
	<atom:link href="http://www.matejunkie.com/tag/id3v2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matejunkie.com</link>
	<description>&#34;Look behind you, a Three-Headed Monkey!&#34;</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.1</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>
	</channel>
</rss>
