jeudi 18 octobre 2018

randomly rename files in php

I have a folder of 1000 images and I need to randomly rename them from 1.jpg to 1000.jpg , it must be completely random each time I run the script. I just need that 1.jpg is different each time I run the script.

all I have to work with so far is the following code. Please help. Thanks

<?php

if (file_exists('Image00001.jpg'))
{
$renamed= rename('Image00001.jpg', '1.jpg');

if ($renamed)
{
echo "The file has been renamed successfully";
}
else
{
echo "The file has not been successfully renamed";
}
}
else
{
echo "The original file that you want to rename does not exist";
}

?>




Aucun commentaire:

Enregistrer un commentaire