您的位置:首页 > 编程语言 > PHP开发

php中批量修改文件后缀名的函数代码

2011-10-23 00:00 716 查看
<?php 
function foreachDir($path){ 
$handle=opendir($path); 
if($handle){ 
while (false !== ($file = readdir($handle))) { 
if($file!="." && $file!='..'){ 
if(is_dir($path.$file)){ 
echo $path.$file."<br/>"; 
foreachDir($path.$file); 
}else{ 
echo "--".$path."/".$file."<br/>"; 
$ext = strripos($file,'.'); 
$aaa = substr($file,0,$ext); 
rename($path.'/'.$file,$path.'/'.$aaa.'.JPG'); 
// die(); 
} 
} 
} 
return false; 
} 
} 
foreachDir('D:\xampp\htdocs\TNF2');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: