当前位置:主页 > 软件编程 > PHP代码 >

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

时间:2021-05-01 09:35:29 | 栏目:PHP代码 | 点击:

复制代码 代码如下:

<?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');

您可能感兴趣的文章:

相关文章