<?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>Admon Home &#187; rename</title>
	<atom:link href="http://www.admon.org/tag/rename/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.admon.org</link>
	<description>Linux System Administration</description>
	<lastBuildDate>Wed, 08 Feb 2012 10:24:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Batch rename files in Linux</title>
		<link>http://www.admon.org/batch-rename-files-in-linux/</link>
		<comments>http://www.admon.org/batch-rename-files-in-linux/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 07:55:35 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[rename]]></category>

		<guid isPermaLink="false">http://planet.admon.org/?p=595</guid>
		<description><![CDATA[Is there any easy ways to batch rename files in Linux? A common requirement is that the web developers may ask you to help rename all *.html files to *.htm, how can we do that? Someone probably will say that they can make a simple script in some minutes to do this kind of things. [...]]]></description>
			<content:encoded><![CDATA[<p>Is there any easy ways to batch rename files in Linux? A common requirement is that the web developers may ask you to help rename all <em>*.html</em> files to<em> *.htm</em>, how can we do that?<span id="more-595"></span></p>
<p>Someone probably will say that they can make a simple script in some minutes to do this kind of things. Actually you don&#8217;t need to recreate the wheel, the operating system have supplied such an utility already, the command is rename, it&#8217;s part of the <a href="http://www.kernel.org/pub/linux/utils/util-linux/">util-linux package</a>.</p>
<p>With the help of this command, it&#8217;s a very easy work to bulk rename files.<br />
But, note that this command is a little different by systems.<br />
Here we&#8217;ll show the usage examples for <strong>rename</strong> in both Redhat / CentOS and Debian / Ubuntu.</p>
<p><strong>1, Batch rename files in Redhat / CentOS</strong><br />
For the scenario we mentioned above, it can be done like this:</p>
<pre>$ rename .html .htm *</pre>
<p>It renames all files in current working directory that match <em>*.html*</em> to <em>*.htm*</em>.<br />
Note that only the first matched occurrence will be modified. If there&#8217;s a file called <em>abc.html.abc.html</em>, after renamed once, the new name is abc.htm.abc.html, not abc.html.abc.htm.</p>
<p><strong>2, Bulk rename files in Debian / Ubuntu</strong><br />
The command here in Debian are quite different which makes it more powerful and professional.<br />
I&#8217;ll show two examples with explaination:</p>
<pre>$ rename -n 's/.html$/htm/' *</pre>
<p><em>-n</em> means no action will be applied, it will shows detailed information on what files would have been renamed:</p>
<pre>$ rename -n 's/.html$/.htm/' abc.html.abc.html
abc.html.abc.html renamed as abc.html.abc.htm</pre>
<p>The expression regunation here is in Perl style, which means you can apply multiple actions at one time, like this:</p>
<pre>$ rename 's/.html$/htm/, s/css/css.backup/, s/jscript/js/' *</pre>
<p>For more details you can raise a forum thread <a href="http://forum.admon.org/linux-scripting/">here at our support forum</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/batch-rename-files-in-linux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Rename a Vserver step by step</title>
		<link>http://www.admon.org/rename-a-vserver-step-by-step/</link>
		<comments>http://www.admon.org/rename-a-vserver-step-by-step/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 03:39:09 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[System Tuning]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[hostname]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[vserver]]></category>

		<guid isPermaLink="false">http://planet.admon.org/?p=522</guid>
		<description><![CDATA[Suppose you made a mistake on the Vserver name when creating it. After finished the installation, you might want to rename your Vserver. This can be accomplished by renaming the config directory and the root for the vserver in question, then modifying some symlinks to match. The general steps are: Stop the vserver in question [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose you made a mistake on the <a href="http://www.linux-vserver.org/Welcome_to_Linux-VServer.org">Vserver</a> name when creating it. After finished the installation, you might want to <strong>rename your Vserver</strong>. This can be accomplished by renaming the config directory and the root for the vserver in question, then modifying some symlinks to match. <span id="more-522"></span></p>
<p>The general steps are:</p>
<ul>
<li> Stop the vserver in question</li>
<p>It can be done by this command: &#8220;<em>vserver  &lt;server name&gt; </em><em>stop</em>&#8221;</p>
<li>Rename the <em>/vservers/&lt;server name&gt;</em> directory</li>
<p>By default it&#8217;s in /vservers, and on some self-crafted versions, it might be re-defined to other path like /var/lib/vservers. Simply you just need to use mv command to rename the issued vserver.</p>
<li>Rename the <em>/etc/vservers/&lt;server name&gt;</em> directory</li>
<p><a href="http://www.nongnu.org/util-vserver/doc/conf/configuration.html">The directory /etc/vservers</a> is much like a system wide configuration directory for vservers, you can use mv to rename specified directory as well.</p>
<li>Update some softlink in <em>/etc/vservers/&lt;server name&gt;</em></li>
<p>update link: /etc/vservers/&lt;server name&gt;/run -&gt; /var/run/vservers/&lt;server name&gt;<br />
update link: /etc/vservers/&lt;server name&gt;/vdir -&gt; /etc/vservers/.defaults/vdirbase/&lt;server name&gt;<br />
update link: /etc/vservers/&lt;server name&gt;/cache -&gt; /etc/vservers/.defaults/cachebase/&lt;server name&gt;<br />
Pay some attention to relative path issue, otherwise these links might get broken, there&#8217;s an example, the current working directory is <em>/etc/vservers/mars</em>:</p>
<pre>joseph@galaxy:/etc/vservers/mars$ ln -s -f /etc/vservers/.defaults/vdirbase/mars vdir</pre>
<li>Update link: /var/run/vservers.rev/&lt;server XID&gt; -&gt; /etc/vservers/&lt;server name&gt;</li>
<p>Please note that this just an update by fixing the dead link, and there&#8217;s no need to create a new XID.</p>
<li>Reset hostname for vserver in question</li>
<p>Basically you just need to modify <em>/etc/vservers/&lt;server name&gt;/uts/nodename</em> before starting the issued vserver, and get other host name related settings modified when system booted.</p>
<pre>joseph@galaxy:/etc/vservers$ grep mars -R mars/ 2&gt;/dev/null -l
mars/uts/nodename
mars/vdir/etc/hosts
mars/vdir/etc/pam_ldap.conf
mars/vdir/etc/mailname
mars/vdir/etc/hostname</pre>
</ul>
<p>Now, It should start properly. If any issue encountered, please don&#8217;t hesitate to <a href="http://forum.admon.org/virtualization/" target="_blank">raise a forum thread</a> at our community forum.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/rename-a-vserver-step-by-step/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

