<?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>Floorplanner Tech Blog &#187; html.erb</title>
	<atom:link href="http://techblog.floorplanner.com/tag/htmlerb/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.floorplanner.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 05 Mar 2010 20:29:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Batch file renaming</title>
		<link>http://techblog.floorplanner.com/2008/09/20/batch-file-renaming/</link>
		<comments>http://techblog.floorplanner.com/2008/09/20/batch-file-renaming/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 07:49:43 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[html.erb]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[rhtml]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=203</guid>
		<description><![CDATA[
			
				
			
		
I just started working on an old Rails project after having neglected it for 15 months. Most of the view files still had the good old .rhtml extension. I was too lazy to rename these files by hand, both on my file system and in the git repository. I used the following Bash commands to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F09%2F20%2Fbatch-file-renaming%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.floorplanner.com%2F2008%2F09%2F20%2Fbatch-file-renaming%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I just started working on an old Rails project after having neglected it for 15 months. Most of the view files still had the good old <code>.rhtml</code> extension. I was too lazy to rename these files by hand, both on my file system and in the git repository. I used the following Bash commands to do the job:</p>
<p>First, I renamed all the partials to the <code>.erb</code> extension. Note: I am not using .html.erb, as some of these partials are used in <code>js</code>-formatted responses as well:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco,monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> app<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/**/</span>_<span style="color: #000000; font-weight: bold;">*</span>.rhtml<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> \
  git <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>\\.rhtml$<span style="color: #000000; font-weight: bold;">/</span>.erb<span style="color: #000000; font-weight: bold;">/`</span>; \
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>The remaining files could now be renamed to <code>.html.erb</code> with a similar command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco,monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> app<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/**/*</span>.rhtml<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> \
  git <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span>\\.rhtml$<span style="color: #000000; font-weight: bold;">/</span>.html.erb<span style="color: #000000; font-weight: bold;">/`</span>; \
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p><small>Note that this technique works with <strong>Subversion</strong> as well: just substitute <code>git</code> with <code>svn</code> in the command above. A regular rename is possible as well by leaving out <code>git</code> altogether!</small> </p>
<p>Now my file names are Rails-compliant again, I can start refactoring all the code that is not up to current Rails standards anymore. Ah, the virtues of developing with a rapidly evolving framework&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/09/20/batch-file-renaming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
