PHP 批量更改文件名
public function actionChangePicsName() { $dir = "D:/beautifulserver/app/extends/头像"; $files1 = scandir($dir); unset($files1[0]); unset($files1[1]); $files1 = array_values($files1); $n = count($files1); for ($i = 0; $i < $n; ++$i){ $title = sprintf('head%.2s', $i + 1); $old_file_name = $dir.'/'.$files1[$i]; $new_file_name = $dir.'/'.$title.strrchr($files1[$i],'.'); rename($old_file_name, $new_file_name); } }