bool rename ( string oldname, string newname [, resource context] )
尝试把 oldname 重命名为 newname。
如果成功则返回 TRUE,失败则返回 FALSE。
例子:
rename( 'tempFile.txt', 'tempFile2.txt' )
$name=$shareInfo['name']
$pos=strrpos($name,".")//右侧查找'.'的位置
//组合条件只处理jpg/png类型的
if($pos &&(substr($name,$pos+1)=="jpg" || substr($name,$pos+1)=="png")){
echo substr($name,0,$pos)
}
方法如下:我重命名的规则是把所有有空格的全部替换成“_”,然后再后面加一个"_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)
$newName = substr($newName, 0,-4)
rename($paths.$entry, $paths.$newName."_s.jpg")
}
$d->close()
echo "done"
?>
以上就是php如何批量修改某个文件夹下所有文件名的方法
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)