#!perl
use strict;
use warnings;
chdir '/root/test';
foreach my $file(glob '*.txt')
{
my $newfile = $file;
$newfile =~ s/\.txt/\.file/;
if(-e $newfile)
{
warn "Cant rename $file to $newfile: $newfile exists\n";
}
elsif (rename $file => $newfile)
{;}
else { warn "rename $file to $newfile failed $!\n";}
}
perl-批量修改文件后缀名
最新推荐文章于 2021-10-29 16:45:32 发布