龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

批量修改文件后缀名

时间:2014-07-22 14:51来源: 作者: 点击:
分享到:
批量修改文件后缀名
批量修改文件后缀名
<?php
function foreachDir($path){
    $handle=opendir($path);
    if($handle){
        while (false !== ($file = readdir($handle))) {
            if($file!="." && $file!='..'){
                if(is_dir($path.$file)){
                    echo $path.$file."<br/>"; 
                    foreachDir($path.$file);
                }else{
                    echo "--".$path."/".$file."<br/>";
                    $ext = strripos($file,'.');
                    $aaa = substr($file,0,$ext);
                    rename($path.'/'.$file,$path.'/'.$aaa.'.JPG');
                    // die();
                }
            }
        }
        return false;
    }
}
foreachDir('D:\xampp\htdocs\TNF2');
精彩图集

赞助商链接