Rename all files of a directory with PHP

Free Scripts :: PHP :: Files and Folders :: Rename all files of a directory with PHP

Author: Salman Javaid

Website: http://www.salman.be

  • How to rename all files of a directory php.
  • Rename all files of a folder with php.
  • Bulk file rename with php

This script renames all the files located in a directory. With below given example we can rename all files of a folder to upper case. You may use other combinations to rename files according to your requirement.

Script

$path='photos/products/';
$handle=opendir($path);

while (($file = readdir($handle))!==false){
    if ($file!="." && $file!=".."){

        rename($path . $file, strtoupper($path . $file));

    }
}

Result

IMAGE01.JPG, IMAGE02.JPG

Comments

No comments. Be the first one.

Leave a comment

Full Name*
Comments*
Security Code*

Our Partners

Getty Icons  Salman Creations
Free High Quality Images  Learn Free Languages 
Opal Hosting  R-Tech Solutions
  • Submit a Script

    Click here to submit your script.