Thread: renaming files
View Single Post
Old 10-18-2007, 10:25 AM   #3 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

So something like this then?

PHP Code:
$images glob($path.'*.jpg'GLOB_BRACE GLOB_NOSORT);
$i 0;

foreach(
$images as $image) {

        if(
$image != $i) {
              
$rename rename($path.$image$path.$i.$format)
              if(
$rename) {
                     echo 
'File: ' .$image' was renamed to ' .$i.$format;
              }
              else {
                     echo 
'File: ' .$image' could not be renamed to ' .$i.$format', please check your chmodding!';
              }
        }
        else {
               echo 
'File: ' .$image' was skipped because it has already the required name!';
        }

        
$i++;


Yes?
Tanax is offline  
Reply With Quote