
Script to Convert Upper Case Filenames to Lower Case
In <2lqqqs$...@apollo3.com> lja...@apollo3.com (Larry James) writes:
: Can someone suggest to me a few lines of shell script that will
:convert filenames in a directory from upper case to lower case.
: Thanks in advance for any comments or suggestions.
:
This appears so frequently it out to be in the FAQ :-).
A perl solution could be:
#!/usr/local/bin/perl
for $oldname (@ARGV) {
($newname = $oldname) =~ tr/A-Z/a-z/;
next if $newname eq $oldname; # no change necessary
if (stat($newname)) { # check for duplicate
printf STDERR "Duplicate %s\n", $newname;
next;
}
rename($oldname, $newname);
exit(0);
__END__
There are lots of other ways to accomplish this, but this is
probably one of the faster methods.
Bill
--
INTERNET: b...@Celestial.COM Bill Campbell; Celestial Software
UUCP: ...!thebes!camco!bill 8545 SE 68th Street
camco!bill Mercer Island, WA 98040; (206) 947-5591
SPEED COSTS MONEY -- HOW FAST DO YOU WANT TO GO?