PHP file batch rename file batch rename tool win7 batch rename files batch folder rename ba

WBOY
Release: 2016-07-29 08:52:55
Original
1104 people have browsed it
$format ='jpg';
                    $path ='C:/Users/12759/Desktop/5.30.120.0';
                    $files = $this->getfile($path,$format);
                    foreach( $files as  $v )
                    {

                    /* //$tv = basename($v);
                     //dd($tv);*/
                     $aa = pathinfo($v);
                     //dd($aa);
                     //list($name,$ext) = explode('.',$tv);
                     //$newname =$path.time().mt_rand(1,10000).'.'.$ext;*/
                     $newname = md5($aa['filename']).'.'.$aa['extension'];
                     //dd($newname);
                    /* if(rename($v,$newname))
                     {
                      echo '成功将'.$v.'重命名'.$newname.'<br />'; 
                     }*/

                     rename($path.'/'.$v,$path.'/'.$newname);    
                     /*echo '成功将'.$v.'重命名'.$newname.'<br />'; */
                     echo "<span style=&#39;color:red&#39;>".$v."</span>"."--------------".$newname."<br/>";

                    }




public function getfile($dirname,$format)
    {
             $dirs    = array();
             $handle = opendir($dirname);
             while(($fn = readdir($handle))!==false){
                 if($fn!='.'&&$fn!='..'){
                 $curDir = $dirname.'/'.$fn;  
                $path = pathinfo($curDir);
                 $dirs[] = $path['basename'];

              }
            }

             return $dirs;
    }
Copy after login

The above introduces the batch renaming of PHP files, including the contents of PHP files and batch renaming. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!