Article 3106 of comp.lang.perl: Xref: feenix.metronet.com comp.lang.perl:3106 Newsgroups: comp.lang.perl Path: feenix.metronet.com!news.utdallas.edu!hermes.chpc.utexas.edu!cs.utexas.edu!geraldo.cc.utexas.edu!portal.austin.ibm.com!awdprime.austin.ibm.com!exeter.austin.ibm.com!woan From: woan@exeter.austin.ibm.com (Ronald S. Woan) Subject: Converting Uppercase file names to Lowercase Sender: news@austin.ibm.com (News id) Message-ID: Date: Tue, 1 Jun 1993 21:59:07 GMT Reply-To: woan@cactus.org References: <1993May28.190121.9827@dsg.tandem.com> Organization: Austin School of Hardknocks Lines: 79 I wrote the following a long time ago, so your mileage might vary: #!/usr/bin/perl 'di'; 'ig00'; # # $Header$ # # $Log$ # quickly renames all mixed case files specified on the commandline into # their lowercase (if invoked as locase) or uppercase (if invoked as # upcase) equivalents. Renames all files in current directory when no # commandline arguments given. # # written by Ronald S. Woan # last revision: 02/10/91 $cl_arguments = @ARGV; if ( $cl_arguments > 0 ) { @filenames = @ARGV; } else { opendir(DIR,'.') || die "Can't open current directory"; @filenames = readdir(DIR); closedir(DIR); } for (@filenames) { next if $_ eq '.'; next if $_ eq '..'; if ( $0 =~ /(([^\/]*)\/)*locase/o ) { if (/[A-Z]/o) { $fname = $_; tr/A-Z/a-z/; system "mv -i $fname $_"; } } elsif ( $0 =~ /(([^\/]*)\/)*upcase/o ) { if (/[a-z]/o) { $fname = $_; tr/a-z/A-Z/; system "mv -i $fname $_"; } } else { die "illegal invocation $0\n"; } } ############################################################### # These next few lines are legal in both Perl and nroff. .00; # finish .ig 'di \" finish diversion--previous line must be blank .nr nl 0-1 \" fake up transition to first page again .nr % 0 \" start at page 1 '; __END__ ##### From here on it's a standard manual page ##### .TH UPCASE 1 "February 11, 1991" .AT 3 .SH NAME upcase, locase \- changes filenames to upper or lower case .SH SYNOPSIS .B upcase [files] .br .B locase [files] .SH DESCRIPTION .I Upcase/Locase changes the filenames of the specified files to uppercase or lowercase depending on whether it was invoked as upcase or locase. Uses all files in the current directory if none were specified on the commandline. .SH AUTHOR Ronald S Woan -- +------All Views Expressed Are My Own And Not Necessarily Shared By IBM-----+ + Ronald S. Woan (IBM VNET)WOAN AT AUSTIN, woan@exeter.austin.ibm.com + + outside of IBM woan@vnet.ibm.com or woan@cactus.org + + others woan@soda.berkeley.edu Prodigy: XTCR74A Compuserve: 73530,2537 +