Home > Backend Development > PHP Tutorial > PHP code to modify file extensions in batches_PHP tutorial

PHP code to modify file extensions in batches_PHP tutorial

WBOY
Release: 2016-07-13 16:55:24
Original
897 people have browsed it

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631686.htmlTechArticle Provides an example of php custom function. This is a php program that can batch modify file suffix names. If necessary Friends can refer to it. The code is as follows Copy the code ?php function...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template