I have files in a folder called 'thumbs'. They have names based on how they were named / renamed by their original authors. I would like to rename them to be two digit sequentially and I managed to find this PHP code:
function sequentialImages($path, $sort=false) {
$i = 1;
$files = glob($path."/{*.gif,*.jpg,*.jpeg,*.png}",GLOB_BRACE|GLOB_NOSORT);
if ( $sort !== false ) {
usort($files, $sort);
}
$count = count($files);
foreach ( $files as $file ) {
$newname = str_pad($i, strlen($count)+1, '0', STR_PAD_LEFT);
$ext = substr(strrchr($file, '.'), 1);
$newname = $path.'/'.$newname.'.'.$ext;
if ( $file != $newname ) {
rename($file, $newname);
}
$i++;
}
}
The php to execute this code is called 'rename.php' and it is found in a folder called 'admin'.
Therefore they are as follows
- 'admin' folder (contains rename.php')
- 'thumbs' folder (contains images with random names)
Both folders are on the same level.
How can I execute 'rename.php' if both are in different folders.
I tried to include $path = '../thumbs';
but it did not function.
Why isn't not working please?