php rename() function returns "No such file or directory" error -


i have folder several images in it.

the folder photos_1/130730782

the images are

.jpg 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg 

i need rename file this

.jpg  = 1.jpg 1.jpg = 2.jpg 2.jpg = 3.jpg 3.jpg = 4.jpg 4.jpg = 5.jpg 5.jpg = 6.jpg 6.jpg = 7.jpg 

i'm using code:

$sysid = '130730782';     $dir = 'photos_1/'.$sysid;      $myphotocount = iterator_count(new directoryiterator($dir)) - 1;      for($i=0; $i<=count($myphotocount); $i++){         $x = $i + 1;         if($i == 0){             rename("{$dir}/.jpg", "{$dir}/1.jpg");         }else{             rename("{$dir}/{$i}.jpg", "{$dir}/{$x}.jpg");         }     } 

i error:

warning: rename(photos_1/130730782/.jpg,photos_1/130730782/1.jpg) [function.rename]: no such file or directory in /home/content/85/6608485/html/mccloskey/rename.php on line 18

warning: rename(photos_1/130730782/1.jpg,photos_1/130730782/2.jpg) [function.rename]: no such file or directory in /home/content/85/6608485/html/mccloskey/rename.php on line 20

i know file exist, doing wrong here?

you'll want rename these files in reverse order.

if rename .jpg 1.jpg, original 1.jpg possibly lost/overwritten.

start highest number, , go backwards.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -