a*******e 发帖数: 3021 | 1 目录里有的是小写文件名,有的是大写,怎么都改成大写? |
L*1 发帖数: 11537 | 2 Try this:
#!/usr/bin/perl
my $dir = "/tmp"; # change it!
print "$dir\n";
opendir(DIR, $dir) || die "Error in opening dir $dir\n";
chdir($dir);
while( ($filename = readdir(DIR)))
{
next if (-d $filename);
print "$filename\n";
my $new_filename = uc($filename);
print "-- $new_filename\n";
#system("mv $filename $new_filename");
}
closedir(DIR);
exit;
~ |
a*******e 发帖数: 3021 | 3 how to run it? save it as a txt and chmod +x?
【在 L*1 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Try this: : #!/usr/bin/perl : my $dir = "/tmp"; # change it! : print "$dir\n"; : opendir(DIR, $dir) || die "Error in opening dir $dir\n"; : chdir($dir); : while( ($filename = readdir(DIR))) : { : next if (-d $filename); : print "$filename\n";
|
j*a 发帖数: 14423 | 4 for i in *; do j=`echo $i | tr a-z A-Z`; echo mv $i $j; done
要是觉得可以就把echo去掉
【在 a*******e 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 目录里有的是小写文件名,有的是大写,怎么都改成大写?
|
a*******e 发帖数: 3021 | 5 thanks a lot.
that's what i am expecting, some simple bash script
bash is so powerful.........
【在 j*a 的大作中提到】![](/moin_static193/solenoid/img/up.png) : for i in *; do j=`echo $i | tr a-z A-Z`; echo mv $i $j; done : 要是觉得可以就把echo去掉 :
|
Z**0 发帖数: 1119 | 6 maybe works.
rename ‘y/a-z/A-Z/’ * |