Provide an example of a PHP custom function. This is a PHP program that can modify file suffix names in batches. Friends in need can refer to it.
代码如下 | 复制代码 |
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'); |