php中批量修改文件后缀名的函数代码,需要的朋友可以参考下。
代码如下:
<?php
function foreachDir($path){
$handle=opendir($path);
if($handle){
while (false !== ($file = readdir($handle))) {
if($file!=”.” && $file!=’..’){
if(is_dir($path.$来源gao.dai.ma.com搞@代*码网file)){
echo $path.$file.”
“;
foreachDir($path.$file);
}else{
echo “–“.$path.”/”.$file.”
“;
$ext = strripos($file,’.’);
$aaa = substr($file,0,$ext);
rename($path.’/’.$file,$path.’/’.$aaa.’.JPG’);
// die();
}
}
}
return false;
}
}
foreachDir(‘D:\xampp\htdocs\TNF2’);
function foreachDir($path){
$handle=opendir($path);
if($handle){
while (false !== ($file = readdir($handle))) {
if($file!=”.” && $file!=’..’){
if(is_dir($path.$来源gao.dai.ma.com搞@代*码网file)){
echo $path.$file.”
“;
foreachDir($path.$file);
}else{
echo “–“.$path.”/”.$file.”
“;
$ext = strripos($file,’.’);
$aaa = substr($file,0,$ext);
rename($path.’/’.$file,$path.’/’.$aaa.’.JPG’);
// die();
}
}
}
return false;
}
}
foreachDir(‘D:\xampp\htdocs\TNF2’);
以上就是php中批量修改文件后缀名的函数代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!