您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php中批量替换文件名的实现代码

2024/7/10 0:26:41发布21次查看
代码如下: 
$dir = 'd:\program files\resource\application\skin\png\\';//注意这里的路径,最后要加两个\,第一个表示转意,但是这样容易遇到其他特定转义,还要仔细判断,可以写为如下方式 
$dir = 'd:/program files/resource/application/skin/png/';//写成这样的路径,就不用担心转义问题了。最后面的/不要漏写 
if ($dh = opendir($dir)) 

while (($file = readdir($dh)) !== false) 

if ($file != . && $file != ..) 

if(filetype($dir . $file) == 'file') 

$newfile = str_replace(array('_png','_xml','_ico'),array('.png','.xml','.ico'), $file); 
var_dump($file.' =======> '.$newfile.'<br />'); 
rename($dir . $file, $dir . $newfile); 



closedir($dh); 
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product