郑州网站建设hnqfu,免费企业网站建站,建设网站的内容,如何查看网站的关键词perl批量改文件后缀
如题#xff0c;perl批量改文件后缀#xff0c;将已有的统一格式的文件后缀#xff0c;修改为新的统一的文件后缀。
#!/bin/perl
use 5.010;print Please input file suffix which U want to rename!\n;
chomp (my $suffix_old )…perl批量改文件后缀
如题perl批量改文件后缀将已有的统一格式的文件后缀修改为新的统一的文件后缀。
#!/bin/perl
use 5.010;print Please input file suffix which U want to rename!\n;
chomp (my $suffix_old ); # 去除输入中的回车符
print Please output file suffix which U want to rename!\n;
chomp (my $suffix_new );foreach my $file(glob *.$suffix_old) {my $new_file $file;$new_file ~ s/\.$suffix_old/.$suffix_new/gm;if (-e $new_file) {warn Cannot rename $file to $new_file: $new_file exists\n;} elsif (rename $file $new_file) {} else {warn rename $file to $new_file failed:$!;}
}