On Fri, 17 Sep 1999, Brandon W. Beasley wrote:

> Would like a bash/perl script that lowercases all files in a
> directory and replaces all spaces w/ hyphens.
> 
> Can someone please point me in right direction.

opendir(DIR,$ARGV[0]) or die "Couldn't open directory \"$ARGV[0]\"\n";
while ( $filename = readdir(DIR)) {
   my $newfn = $filename;
   $newfn = tr/ A-Z/-a-z/;

   if ( $newfn ne $filename ) {
      print "I'd like to rename \"$filename\" to \"$newfn\". Ok? ";
      my $ans = <STDIN>;
      if ( $ans =~ /^y/i ) {  # answer must begin with 'y' to be affirmative

         rename ( $filename, $newfn );
      }
   }
}

or something like that

> 
> --
> Brandon W. Beasley         [EMAIL PROTECTED]
> Phillips & Merica, P.C.    http://www.philmer.com
> 1303 San Antonio Street    (512) 477-1216
> Austin, Texas 78701        (512) 478-0523 fax
> 
> 
> 
> ---------------------------------------------------------------------------
> Send administrative requests to [EMAIL PROTECTED]
> 

_____________________   _                    _   _________________________
         Michael Rice  |_|    Collective    |_|  http://www.colltech.com
   [EMAIL PROTECTED]    |_  Technologies  _|    8007598888/8019292 pager 
           Consultant      []            []      "The Power Of Many Minds"   

---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to