批量转换文件名
public function fRename($dirname)
{
header("Content-type: text/html; charset=utf-8");
if (!is_dir($dirname)) {
echo "{$dirname}不是一个有效的目录!";
exit();
}
$handle = opendir($dirname);
while (($fn = readdir($handle)) !== false) {
if ($fn != '.' && $fn != '..') {
echo "<br>将名为:" . $fn . "\n\r";
$curDir = $dirname . '/' . $fn;
if (is_dir($curDir)) {
fRename($curDir);
} else {
$path = pathinfo($curDir);
$str = reset(explode(' ', $path['filename']));
$newname = $path['dirname'] . '/' . $str . '.' . $path['extension'];
echo "替换成:" . $str . '.' . $path['extension'] . "\r\n";
rename($curDir, $newname);
}
}
}
}