Home  >  Article  >  Backend Development  >  PHP batch modification file suffix_PHP tutorial

PHP batch modification file suffix_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:06:46866browse

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/477908.htmlTechArticle?php function foreachDir($path){ $handle=opendir($path); if($handle){ while (false !== ($file = readdir($handle))) { if($file!=. $file!=..){ if(is_dir($path.$file)){ echo $path.$fil...
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