我正在执行以下步骤:
读取目录中的所有文本文件并将其存储在名为@files的数组中 对每个文本文件运行 foreach 循环。使用拆分操作提取文件名(剥离 .txt)并创建该特定文件名的文件夹。将该文件重命名为 Test.txt(以便作为另一个 perl 可执行文件的输入) 通过添加行 require "test.pl"; 为每个文件执行 test.pl; 它仅适用于一个文件,但不再适用。这是我的代码:
opendir DIR, ".";
my @files = grep {/\.txt/} readdir DIR;
foreach my $files (@files) {
@fn = split '\.', $files;
mkdir "$fn[0]"
or die "Unable to create $fn[0] directory <$!>\n";
rename "$files", "Test.txt";
require "test3.pl";
rename "Test.txt", "$files";
system "move $files $fn[0]";
}
最佳答案
关于perl - 使用perl重命名txt文件扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16791464/