<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Little Brain &#187; programming</title>
	<atom:link href="http://justalittlebrain.wordpress.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://justalittlebrain.wordpress.com</link>
	<description>just a little brain</description>
	<lastBuildDate>Fri, 27 Jan 2012 09:05:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='justalittlebrain.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Little Brain &#187; programming</title>
		<link>http://justalittlebrain.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://justalittlebrain.wordpress.com/osd.xml" title="Little Brain" />
	<atom:link rel='hub' href='http://justalittlebrain.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Replace Space With Underscore in Filename</title>
		<link>http://justalittlebrain.wordpress.com/2008/10/19/replace-space-with-undescore-in-filename/</link>
		<comments>http://justalittlebrain.wordpress.com/2008/10/19/replace-space-with-undescore-in-filename/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 13:37:12 +0000</pubDate>
		<dc:creator>kriwil</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://littlebrain.org/?p=195</guid>
		<description><![CDATA[This is merely my personal note. I was about to rename all my files under a directory. I need to replace the space with underscore character ('_'). My first thought was a simple bash script to do that. Apparently, it&#8217;s been very long time since my last bash coding session. I spent 15 minutes reading [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justalittlebrain.wordpress.com&amp;blog=31033593&amp;post=195&amp;subd=justalittlebrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is merely my personal note. I was about to rename all my files under a directory. I need to replace the space with underscore character <code>('_')</code>. My first thought was a simple bash script to do that. Apparently, it&#8217;s been very long time since my last bash coding session. I spent 15 minutes reading how to read all files and rename them. And I got nothing.</p>
<p>Luckily, I know python. Stupid me. Why didn&#8217;t I think it at first time. It was couple minutes of python and all the spaces were replaced by underscores. Thanks to python. All I did were</p>
<pre>
$ python
Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import os
&gt;&gt;&gt; files = os.listdir('./')
&gt;&gt;&gt; for f in files:
...     os.rename(f, f.replace(' ', '_'))
...
&gt;&gt;&gt;
</pre>
<p>Or if you want to save in a script, you could you this</p>
<pre>
#!/usr/bin/python

import os
import sys

files = os.listdir(sys.argv[1])
for f in files:
    os.rename(f, f.replace(' ', '_'))
</pre>
<p>The script takes the directory path as the argument. You could modify the script to use regex to have a better rename rule <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/justalittlebrain.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/justalittlebrain.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/justalittlebrain.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/justalittlebrain.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/justalittlebrain.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/justalittlebrain.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/justalittlebrain.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/justalittlebrain.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/justalittlebrain.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/justalittlebrain.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/justalittlebrain.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/justalittlebrain.wordpress.com/195/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/justalittlebrain.wordpress.com/195/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/justalittlebrain.wordpress.com/195/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=justalittlebrain.wordpress.com&amp;blog=31033593&amp;post=195&amp;subd=justalittlebrain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://justalittlebrain.wordpress.com/2008/10/19/replace-space-with-undescore-in-filename/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/17b185ab2d1b7dcad3f488040f76385c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kriwil</media:title>
		</media:content>
	</item>
	</channel>
</rss>
