[Techtalk] Uppercase to lowercase
Jacinta Richardson
jarich at perltraining.com.au
Thu Dec 5 13:54:05 EST 2002
On Wed, 4 Dec 2002, Phil Savoie wrote:
> Hi All,
>
> Was wondering if anyone had a script they would like to share to convert
> upercase filenames to lowercase?
Here's one that might work for you:
====== cut ======
#!/usr/bin/perl -w
use strict;
use File::Copy;
# use "." for the path if you want the current directory.
my $directory = "/some/path/to/files";
opendir DIR, $directory or die "Failed to open $directory: $!";
# Take each file at a time (order is not guaranteed)
foreach my $file (readdir DIR)
{
# don't bother with it if it's already lowercase
next if ($file eq lc($file));
# get lowercase name and move it.
my $lowercase_name = lc($file);
move("$directory/$file", "$directory/$lowercase_name");
}
exit 0;
====== cut ======
--
("`-''-/").___..--''"`-._ | Jacinta Richardson |
`6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
(_Y_.)' ._ ) `._ `. ``-..-' | +613 9354 6001 |
_..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
(il),-'' (li),' ((!.-' | www.perltraining.com.au |
More information about the Techtalk
mailing list