title: batch-renaming file name in a directory
body: <p>I have some files with names like this:</p>
  
  <pre><code>01_dpm_gsi_182.sl5
  02_dpm_devel_gsi_182.sl5
  03_DPM_DSI_181.sl5
  04_globus_httpd_122.sl5
  05_globus_httpd_client_cgi_132.sl5
  </code></pre>
  
  <p>How can I rename those files, so that I get some thing like:</p>
  
  <pre><code>01_dpmgsi_s2011e01.sl5
  02_dpmdevelgsi_s2011e02.sl5
  ....
  ....
  </code></pre>
  
  <p>The closest I was suggested as like this:</p>
  
  <pre><code>#!/usr/bin/perl -n
  
  if (/^([^_]+)_(.+)_([^.]+)([.].+)$/) {
      my $s = $&amp;;
      my $x = $1;
      my $y = $2;
      my $z = 2011;
      my $e = $4;
  
      $y =~ s/_//g;
  
      print "mv $s ${x}_${y}_s${z}e$x$e\n"
  }
  </code></pre>
  
  <p>and then use it like this:</p>
  
  <pre><code># ls | perl -n reName.pl &gt; output
  # bash ./output
  </code></pre>
  
  <p>Is there any better way or one-liner to do this, possibly using sed/awk? Cheers!!</p>