This is not what you're looking for... Does it need to be a command line?
try this short script, instead:
-----Begin Script------
#!/usr/local/bin/perl
use strict;
use File::Copy;
use vars qw/$startDir/;
my $startDir = shift;
upperFilesInDir($startDir);
sub upperFilesInDir {
my $dir = shift;
$dir = formatDir($dir);
opendir(SOURCE,$dir);
my @files = grep(!/^.+$/,grep(/^(a-z0-9\W)+$/,readdir(SOURCE)));
for my $file (@files) {
if (-d $dir . $file) {
upperFilesInDir($dir . $file);
} else {
my $newFile = $file;
$newFile =~ tr/a-z/A-Z/;
move($dir . $file,$dir . $newFile);
}
}
}
sub formatDir {
my $dir = shift;
($dir .= '/') unless ($dir =~ |/$|);
return $dir;
}
-----End Script--------
You could make it even shorter, if you want, but I left out a lot of
"elegance" so you could see
- the internals of directory recursion
- the tests for which files to operate on
- the seperate parts of the process
and modify them if they don't fit your needs exactly. This script takes
the directory to start in as the argument, and operates on all files which
DO NOT contain capital letters.
Regards,
Michael Donnelly
74 Orange Street $2
Waltham, MA 02453
(781) 856-7018
On Fri, 9 Feb 2001, [EMAIL PROTECTED] wrote:
> Did you see the tr command syntax is somewhat like,
> tr/a-z/A-Z/
>
> I dont have the exact syntax in top of my head, but you can check it in
> documentation.
>
> Nasir Kamal
>
>
> -----Original Message-----
> From: Dennis Smith [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 09, 2001 7:32 AM
> To: [EMAIL PROTECTED]
> Subject: [Perl-unix-users] command interpreter uppercase files
>
>
> Hi perl users,
>
>
>
> I have ftp some files from NT to unix and it has put all my files in
> lowercase.
>
> Is there a way to use the perl command line to uppercase all my files.
>
>
>
> should be something perl -p -e ??? *
>
> output would be filea to FILEA
>
>
>
> I know how to use sed buit I dont know how to change the file to upercase
> FILE.
>
>
>
> If you have a script that would do this I really would apprciate the help.
>
>
>
>
>
> Thanks
>
>
>
> _______________________________________________
> Perl-Unix-Users mailing list. To unsubscribe go to
> http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users
> _______________________________________________
> Perl-Unix-Users mailing list. To unsubscribe go to
>http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users
>
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users