Hi Everyone,
I am a complete perl noob but I am trying to learn! I am trying to
write a script that will make all the filenames in a directory
lowercase.
So say we have TEST.TXT & TEST1.TXT
I want the script to turn them into test.txt & test.txt
Here is what i have so far:
print "\nWhere are the files? ";
$dir = <stdin>;
chomp ($dir);
opendir (DIRECTORY, $dir);
@files = readdir (DIRECTORY);
Now I know need a foreach loop and I keep trying to use the function
lc but it doenst seem to work.
I found a script on the net that does what does exactly what I am
asking but it is a little over my head now. I would prefer to do it
my way and learn as I go rather then try to bite off more then I can
chew.
Here is that script. Please help me make it work with what i have. I
am just adding the other script in case anyone is looking for a
working one.
my $path_to_dir = shift;
dir("$path_to_dir");
sub dir {
opendir(DIR,"$_[0]");
my @list_of_files = readdir(DIR);
foreach(@list_of_files) {
if($_ ne "." && $_ ne "..") {
if(-d "$_[0]/$_") {
dir("$_[0]/$_");
}
else {
rename "$_[0]/$_","$_[0]/"."\L$_";
}
}
}
}
TIA
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs