<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:at="http://www.sixapart.com/ns/at"
    xmlns:icbm="http://postneo.com/icbm"
    xmlns:rvw="http://purl.org/NET/RVW/0.2/"
    xmlns:media="http://search.yahoo.com/mrss">
    <channel>
        <title>A matter of fiction</title>
        <link>http://jonathanj.vox.com/library/posts/tags/python/page/1/</link>
        <description>When you meet a man who is not a poet, do not show him your poem.</description>
        <language>en</language>
        <generator>Vox</generator>
        <lastBuildDate>Wed, 09 May 2007 00:50:00 +0200</lastBuildDate>
        <copyright>Copyright 2007</copyright>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs> 

        <category domain="http://jonathanj.vox.com/tags/">python</category> 


 
        <item>
            <title>Renaming files in style</title>
            <link>http://jonathanj.vox.com/library/post/renaming-files-in-style.html?_c=feed-rss-full</link>
    
    
    
            <author>nobody@vox.com(jonathanj)</author>
            <comments>http://jonathanj.vox.com/library/post/renaming-files-in-style.html?_c=feed-rss-full</comments>
            <guid isPermaLink="true">http://jonathanj.vox.com/library/post/renaming-files-in-style.html?_c=feed-rss-full</guid> 
            <pubDate>Wed, 09 May 2007 00:50:00 +0200</pubDate>
            
            
            <description>
    
        
            
            &lt;p&gt;Once upon a time I wrote about a piece of software of mine, a stack-oriented file renaming tool. I thought this was rather nifty as I have only ever seen the regular-expression-hell approach to renaming files where you have a regular expression that can actually cause grievous bodily harm, you use this to (hopefully) match the parts of the filename that you want to keep (or alter) and then construct your new filename from these components; all in all, a bit like drying yourself off with a vacuum cleaner.&lt;/p&gt;&lt;p&gt;Often you actually want to perform relatively complex tasks on some of these filename components, like &amp;quot;proper&amp;quot; casing a title or looking up a TV episode name from the season number, show name and episode number. In these situations, a stack-oriented approach gives you better flexibility because you can program the behaviour (assuming a reasonable set of basic functions) with something a little more sturdy than regular expressions&lt;/p&gt;&lt;p&gt;After working on my original code a bit more, I found I could leverage these strengths to do a lot of really repetitive work for me, such as renaming TV episodes and so rn was born. You can run an rn script over a given set of filenames and have it work its magic, which is obviously where you can save yourself a lot of time and effort. My pride and joy is my TV episode renaming script, it&amp;#39;s process is as follows:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Split a filename into it&amp;#39;s useful parts (series name, season number, episode number) according to a set of regular expressions that match the most common naming conventions.&lt;/li&gt;&lt;li&gt;Query tvrage.com&amp;#39;s &amp;quot;raw data&amp;quot; service with the information we have.&lt;/li&gt;&lt;li&gt;Rename the file according to the data we get back.&lt;/li&gt;&lt;/ul&gt;Tristan has been contributing to the code and actively uses rn (as do I.) You can find the darcs repos at &lt;a href=&quot;http://slipgate.za.net/%7Ekorpse/darcs/rn&quot;&gt;http://slipgate.za.net/~korpse/darcs/rn&lt;/a&gt; and &lt;a href=&quot;http://slipgate.za.net/%7Emithrandi/darcs/rn&quot;&gt;http://slipgate.za.net/~mithrandi/darcs/rn&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;
        
    
            
                &lt;p style=&quot;clear:both;&quot;&gt; 
    &lt;a href=&quot;http://jonathanj.vox.com/library/post/renaming-files-in-style.html?_c=feed-rss-full#comments&quot;&gt;Read and post comments&lt;/a&gt;   |   
    &lt;a href=&quot;http://www.vox.com/share/6a00cd972815d04cd500d414340a816a47?_c=feed-rss-full&quot;&gt;Send to a friend&lt;/a&gt; 
&lt;/p&gt;

            
            </description>
    
            <category domain="http://jonathanj.vox.com/tags/">python</category>
    
            <category domain="http://jonathanj.vox.com/tags/">rn</category>
    
        
        
        </item>

    </channel>
</rss>

