<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Sundaryourfriend's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 07:05:05 GMT</pubDate>
    <description>DZone Snippets: Sundaryourfriend's Code Snippets</description>
    <item>
      <title>Convert extensions of files to lowercase using perl</title>
      <link>http://snippets.dzone.com/posts/show/4186</link>
      <description>1. Searches for files having uppercase extensions (can be mixed with numbers and can be multipart eg: TAR.BZ2 ). &lt;br /&gt;   It does not detect files whose extensions contain both upper and lower cases.  This is intentional, as if you have part of extension lowercase, you probably intentionally left the other part upper case. Changing this behaviour is trivial. Replace that complex (?:[A-Z]*[0-9]*\.*) with a . (a dot). &lt;br /&gt;&lt;br /&gt;2. It then converts them to lowercase.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;$files=`ls`;&lt;br /&gt;@files=split(/\n/,$files);&lt;br /&gt;foreach (@files) {&lt;br /&gt;    if(/(.*)\.((?:[A-Z]*[0-9]*\.*)+)$/) {&lt;br /&gt;        $name=$1."."."\L$2\E";&lt;br /&gt;        system("mv $_ $name")&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Looks quite ugly, but this is what I could do with the Perl I know, and more importantly, it works (at least in my case)!</description>
      <pubDate>Thu, 21 Jun 2007 18:16:09 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4186</guid>
      <author>sundaryourfriend (Sundara Raman)</author>
    </item>
  </channel>
</rss>
