php手册:
bool rename ( string oldname, string newname [, resource context] )
尝试把 oldname 重命名为 newname.
如果成功则返回 TRUE,失败则返回 FALSE.
例子:
rename方法,
rename — 重命名一个文件或目录
bool rename ( string $oldname , string $newname [, resource $context ] )
方法如下:我重命名的规则是把所有有空格的全部替换成"_",然后再后面加一个"_s".
php
$paths = "C://Documents and Settings//sk//Desktop//s//";
$d = dir($paths);
while (false !== ($entry = $d-read())) {
$table_change = array(' '='_');
$newName = strtr($entry,$table_change);
rename($paths.$entry, $paths.$newName."_s.jpg");
}
$d-close();
echo "done";
以上就是土嘎嘎小编为大家整理的用php怎么改文件名相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!