<?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>SavvyAdmin.com &#187; Shell</title>
	<atom:link href="http://savvyadmin.com/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://savvyadmin.com</link>
	<description>For savvy admins everywhere...</description>
	<lastBuildDate>Sun, 20 Jun 2010 21:53:13 +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>Batch MP3 Encoding with Linux and LAME</title>
		<link>http://savvyadmin.com/batch-mp3-encoding-with-linux-and-lame/</link>
		<comments>http://savvyadmin.com/batch-mp3-encoding-with-linux-and-lame/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 20:32:14 +0000</pubDate>
		<dc:creator>gmendoza</dc:creator>
				<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[LAME]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MP3]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.savvyadmin.com/2007/12/02/batch-mp3-encoding-with-linux-and-lame/</guid>
		<description><![CDATA[If you have a number of audio files that you would like to convert to mp3, but don&#8217;t want to hassle with graphical applications, there is a simple way to accomplish the task using Linux, LAME and a little shell scripting. By performing a basic &#8220;for loop&#8221; to invoke LAME, you can easily convert any [...]


Related posts:<ol><li><a href='http://savvyadmin.com/add-stereo-audio-tracks-to-mkv-files/' rel='bookmark' title='Permanent Link: Add Stereo Audio Tracks to MKV Files'>Add Stereo Audio Tracks to MKV Files</a></li>
<li><a href='http://savvyadmin.com/mp3-tag-editing-in-linux/' rel='bookmark' title='Permanent Link: MP3 Tag Editing in Linux'>MP3 Tag Editing in Linux</a></li>
<li><a href='http://savvyadmin.com/amazon-mp3-downloader-for-linux/' rel='bookmark' title='Permanent Link: Amazon MP3 Downloader for Linux!'>Amazon MP3 Downloader for Linux!</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you have a number of audio files that you would like to convert to mp3, but don&#8217;t want to hassle with graphical applications, there is a simple way to accomplish the task using Linux, LAME and a little shell scripting.  By performing a basic &#8220;for loop&#8221; to invoke LAME, you can easily convert any group of audio files using one line of shell code.</p>
<p>Here is an example of a &#8220;for loop&#8221; that runs the command &#8220;lame&#8221; against a set of files in your current working directory with the .wav file extension.</p>
<blockquote><pre>$ for f in *.wav ; do lame $f ; done</pre>
</blockquote>
<p>If your audio file names have spaces in them, then you will need to use quotation marks around &#8220;$f&#8221; variable.</p>
<blockquote><pre>$ for f in *.wav ; do lame "$f" ; done</pre>
</blockquote>
<p>I typically create my original audio files <em>without</em> the file name extension of <em>.wav</em> or <em>.au</em>.   This is because when you run lame against a file name, and do not omit the extension in the output option, the resulting file will have two extensions in the file name.  e.g. <em>filename.wav.mp3</em>.  Yes, I can use <em>sed</em> or <em>basename</em> in the for loop to prevent this, but to keep it simple, I just choose to not use the file extension to begin with.</p>
<p>If you are working with a group of files that have all been named using the convention of &#8220;Artist &#8211; Album &#8211; ## &#8211; Track Title&#8221;, (notice the spaces in the name), the following will work.</p>
<blockquote><pre>$ for f in Artist\ -\ Album* ; do lame "$f" ; done</pre>
</blockquote>
<p>Once the job is finished, you will be left with a directory full of your original audio files, and your newly created mp3&#8242;s.</p>
<p><strong>Extra Credit</strong></p>
<p>Okay, since we&#8217;re on the topic of shell scripting.  If you want to delete  all the original audio files (the ones without any file name extensions), and without first moving the new mp3&#8242;s to a different directory, one overly complicated example would be the following.</p>
<blockquote><pre>for f in *.mp3 ; do AUFILE=`basename "$f" .mp3` ; rm "$AUFILE"; done</pre>
</blockquote>
<p>This would have been easier if the original files could have been identified with .wav extensions, (rm *.wav), but since they had no file extensions to begin with, a wild card alone would not work.  Now folks, this is <em>just</em> an example, and there&#8217;s a million other ways you can go about this.  But in any case, I hope it helps you start exploring on your own!</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F&amp;partner=sociable" title="Print"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F&amp;t=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME" title="Facebook"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://twitter.com/home?status=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME%20-%20http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F" title="Twitter"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F&amp;title=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME&amp;notes=If%20you%20have%20a%20number%20of%20audio%20files%20that%20you%20would%20like%20to%20convert%20to%20mp3%2C%20but%20don%27t%20want%20to%20hassle%20with%20graphical%20applications%2C%20there%20is%20a%20simple%20way%20to%20accomplish%20the%20task%20using%20Linux%2C%20LAME%20and%20a%20little%20shell%20scripting.%20%20By%20performing%20a%20basic%20%22for%20" title="del.icio.us"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://savvyadmin.com/feed/" title="RSS"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F&amp;title=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME&amp;bodytext=If%20you%20have%20a%20number%20of%20audio%20files%20that%20you%20would%20like%20to%20convert%20to%20mp3%2C%20but%20don%27t%20want%20to%20hassle%20with%20graphical%20applications%2C%20there%20is%20a%20simple%20way%20to%20accomplish%20the%20task%20using%20Linux%2C%20LAME%20and%20a%20little%20shell%20scripting.%20%20By%20performing%20a%20basic%20%22for%20" title="Digg"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME&amp;body=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F" title="email"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F&amp;title=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME&amp;source=SavvyAdmin.com+For+savvy+admins+everywhere...&amp;summary=If%20you%20have%20a%20number%20of%20audio%20files%20that%20you%20would%20like%20to%20convert%20to%20mp3%2C%20but%20don%27t%20want%20to%20hassle%20with%20graphical%20applications%2C%20there%20is%20a%20simple%20way%20to%20accomplish%20the%20task%20using%20Linux%2C%20LAME%20and%20a%20little%20shell%20scripting.%20%20By%20performing%20a%20basic%20%22for%20" title="LinkedIn"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F" title="Identi.ca"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F&amp;title=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME&amp;annotation=If%20you%20have%20a%20number%20of%20audio%20files%20that%20you%20would%20like%20to%20convert%20to%20mp3%2C%20but%20don%27t%20want%20to%20hassle%20with%20graphical%20applications%2C%20there%20is%20a%20simple%20way%20to%20accomplish%20the%20task%20using%20Linux%2C%20LAME%20and%20a%20little%20shell%20scripting.%20%20By%20performing%20a%20basic%20%22for%20" title="Google Bookmarks"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsavvyadmin.com%2Fbatch-mp3-encoding-with-linux-and-lame%2F&amp;title=Batch%20MP3%20Encoding%20with%20Linux%20and%20LAME" title="StumbleUpon"><img src="http://savvyadmin.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://savvyadmin.com/add-stereo-audio-tracks-to-mkv-files/' rel='bookmark' title='Permanent Link: Add Stereo Audio Tracks to MKV Files'>Add Stereo Audio Tracks to MKV Files</a></li>
<li><a href='http://savvyadmin.com/mp3-tag-editing-in-linux/' rel='bookmark' title='Permanent Link: MP3 Tag Editing in Linux'>MP3 Tag Editing in Linux</a></li>
<li><a href='http://savvyadmin.com/amazon-mp3-downloader-for-linux/' rel='bookmark' title='Permanent Link: Amazon MP3 Downloader for Linux!'>Amazon MP3 Downloader for Linux!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://savvyadmin.com/batch-mp3-encoding-with-linux-and-lame/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
