Home  >  Article  >  Backend Development  >  Function code for batch modifying file suffix names in PHP_PHP tutorial

Function code for batch modifying file suffix names in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:23:16793browse

复制代码 代码如下:

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:xampphtdocsTNF2');

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/324514.htmlTechArticle复制代码 代码如下: ?php function foreachDir($path){ $handle=opendir($path); if($handle){ while (false !== ($file = readdir($handle))) { if($file!="." $file!='..'){ if(is_di...
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