<?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>Claus Witt &#187; mp3</title>
	<atom:link href="http://www.clauswitt.com/tag/mp3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clauswitt.com</link>
	<description>software and web developer</description>
	<lastBuildDate>Thu, 24 Jun 2010 20:07:03 +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>How I sorted All My Mp3&#8242;s With a Simple Bash Script</title>
		<link>http://www.clauswitt.com/how-i-sorted-all-my-mp3s-with-a-simple-bash-script/</link>
		<comments>http://www.clauswitt.com/how-i-sorted-all-my-mp3s-with-a-simple-bash-script/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 21:00:00 +0000</pubDate>
		<dc:creator>Claus Witt</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mp3]]></category>

		<guid isPermaLink="false">http://www.clauswitt.com/?p=181</guid>
		<description><![CDATA[First of all, the headline is a lie. I am in the process of copying all mp3 files that we in our household have had on a number of different machines to one central server, which all computers talk to via webdav. But since we have had a lot of different naming schemes and ways [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, the headline is a lie. I am in the process of copying all mp3 files that we in our household have had on a number of different machines to one central server, which all computers talk to via webdav. But since we have had a lot of different naming schemes and ways of sorting files we needed some sort of uniform naming of files and directories. We decided on the ever so nice /Artist/Album/01_Title.mp3. But since we have a lot of mp3&#8242;s, this seemed a daunting task. </p>
<p>In comes bash. 6 lines of code is all it takes. </p>
<pre name="code" class="bash">
#!/bin/bash
end="/destination/dir/of/mp3s"
find -type f -name *.mp3 -print0 | while read -d  $'\0' file; do
        mkdir --parent "$end"/"$(mp3info -f -p %a "$file")"/"$(mp3info -f -p %l "$file")"
        mv "$file" "$end"/"$(mp3info -f -p %a "$file")"/"$(mp3info -f -p %l "$file")"/"$(mp3info -f -p %n "$file")"_"$(mp3info -f -p %t "$file")".mp3
done
</pre>
<p>The small program mp3info is used to extract id3 tags from the files. (Fortunately they are entered for almost all files). I am not the greatest bash-hacker in the world, so there might be a better way to do this. But I have tested this, and it works, and is quite fast. </p>
<p>If you know of a better way to do this, please comment. I would love to learn. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.clauswitt.com/how-i-sorted-all-my-mp3s-with-a-simple-bash-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
