<?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>Le Vosgien du Net &#187; 2008 &#187; décembre</title>
	<atom:link href="http://levosgien.net/2008/12/feed/" rel="self" type="application/rss+xml" />
	<link>http://levosgien.net</link>
	<description>Parce que la vérité n'est pas toujours bonne à dire</description>
	<lastBuildDate>Thu, 11 Feb 2010 18:39:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Onliner Batch Rename Files with Bash</title>
		<link>http://levosgien.net/2008/12/13/onliner-batch-rename-files-with-bash/</link>
		<comments>http://levosgien.net/2008/12/13/onliner-batch-rename-files-with-bash/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 12:39:35 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Geekitude]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sysa]]></category>

		<guid isPermaLink="false">http://levosgien.net/?p=142</guid>
		<description><![CDATA[	Because I&#8217;m fed of searching for this kind of useful command :
$ for F in *; do E=${F:(-4)}; B=${F/$E/}; mv $F 'Wonderful.Serial.FileName.S03E'$B.'VOSTFR.HDTV.XViD.GKS'$E; done

	Explanations :
E = ${F:(-4)} extracts the file extension.
B = ${F/$E/} returns the original filename without extension.
	These two variables are then used to build the new filename  
	[EDIT]
	Another one, using sed and regular [...]]]></description>
			<content:encoded><![CDATA[	<p>Because I&#8217;m fed of searching for this kind of useful command :</p>
<code>$ for F in *; do E=${F:(-4)}; B=${F/$E/}; mv $F 'Wonderful.Serial.FileName.S03E'$B.'VOSTFR.HDTV.XViD.GKS'$E; done
</code>
	<p>Explanations :<br />
<code>E = ${F:(-4)}</code> extracts the file extension.</p>
<code>B = ${F/$E/}</code> returns the original filename without extension.
	<p>These two variables are then used to build the new filename <img src='http://levosgien.net/wp/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
	<p><strong>[EDIT]</strong></p>
	<p>Another one, using sed and regular expressions :</p>
<code>$ for A in *.avi; do mv "$A" `echo $A | sed -r 's/^Name To Remove &lt;ins&gt;([0-9]&lt;/ins&gt;(-[0-9]+)?)\.avi$/\1.avi/'`; done</code>
	<p>Were we build a simple &#8220;mv&#8221; command with the original filename ($A) and a new filename by catching the output of <code>echo $A | sed</code> enclosing it with backquotes (`).</p>
	<p>sed -r allows to use extended regular expressions.</p>
	<p>s/you/me/ is the sed command to Subsitute you by me.</p>
	<p>s/^Name To Remove <ins>([0-9]</ins>(-[0-9]+)?)\.avi$/\1.avi/</p>
	<p>We match filenames like :
	<ul>
		<li>Name To Remove 123.avi (as many spaces as you want between the textual part of the name and the file number)</li>
		<li>Name To Remove 123-456.avi</li>
	</ul></p>
	<p>We catch the subexpression between parenthesis (123 or 123-456 in this poor example) and we use it to build the new filename (thanks to &#8221;\1&#8221; in the third part of the sed command.)</p>

 ]]></content:encoded>
			<wfw:commentRss>http://levosgien.net/2008/12/13/onliner-batch-rename-files-with-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
