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
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




