3
我需要重命名所有的歌曲用下面的PHP代码整数(数字),但它显示了一个错误:PHP7重命名的目录迭代器中的所有文件(Windows 10)的64位XAMPP
Warning: rename(abc.mp3,2.4): The system cannot find the file specified. (code: 2) in D:\xampp\htdocs\hta\file_renames.php on line 14
命令PATHINFO_EXTENSION在这里也不行? 我使用与XAMPP(PHP7)窗口10
<?php $total = 0;
$dir = "songs/";
foreach (new DirectoryIterator($dir) as $fileInfo) {
if(!$fileInfo->isDot()){
$total +=1;
$file = $fileInfo->getFilename();
rename($file,$total.'.'.PATHINFO_EXTENSION);
}
}
echo('Total files: '.$total);
?>
如何我所有的.mp3文件重命名为number.mp3文件?循环内?
感谢它现在工作得很好。谢谢 –