PHP implementation of bulk modified file suffix method, _php tutorial

Source: Internet
Author: User

PHP implementation of the bulk modification of the file suffix name method,


In this paper, we describe the method of PHP to implement batch modification of file suffix name. Share to everyone for your reference. Specific as follows:

/** * Bulk Modify file suffix name * @param $path folder path * @param $sext original file suffix ($sext =all all files throughout the directory) * @param $dext destination file suffix * @return void
  */function Foreachdir ($path, $sext, $dext) {   $handle =opendir ($path);   if ($handle) {while   (false!== ($file = Readdir ($handle))) {    if ($file! =). "&& $file! = ' ... ') {     if (Is_dir ($path. $file)) {      Foreachdir ($path. $file);     } else{      $ext = Strripos ($file, '. ');      $fileName = substr ($file, 0, $ext);      $SRC = $path. ' /'. $file;     $dest = $path. ' /'. $fileName. '. $dext;     if ($sext! = "All") {      if ($sext = = substr ($src, 0-strlen ($sext))) rename ($src, $dest);      } else{      Rename ($src, $dest);    }}} return false;   } }foreachdir (' C:\Users\chenlinzhong\Desktop\redis-stable\src ', ' C ', ' txt ');

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/1040823.html www.bkjia.com true http://www.bkjia.com/PHPjc/1040823.html techarticle PHP Implementation of the method of batch modification of file suffix, this article describes the PHP implementation of bulk modified file suffix method. Share to everyone for your reference. Specific as follows:/** * Batch repair ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.