Home  >  Article  >  Backend Development  >  php中批量修改文件后缀名的函数代码_php技巧

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

WBOY
WBOYOriginal
2016-05-17 09:15:00856browse
复制代码 代码如下:

function foreachDir($path){
$handle=opendir($path);
if($handle){
while (false !== ($file = readdir($handle))) {
if($file!="." && $file!='..'){
if(is_dir($path.$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');
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn