I have a folder with the several images in it. 

The folder is `photos_1/130730782`

The images are

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

```

I need to rename the file like 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 this 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 get this 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 the file exist, what am I doing wrong here?