<?php
require('includes/application_top.php');
$select_products_id = "select products_name,products_image from cfpl0594";
$products_res_cf = $db->Execute($select_products_id);
while(!$products_res_cf->EOF)
{
$products_image = $products_res_cf->fields['products_image'];
$new_name_no_extension = $products_res_cf->fields['products_name'];
$products_image_extension = substr($products_image, strrpos($products_image, '.'));
$products_image_no_extension = str_replace($products_image_extension, '', $products_image);
if ($dir = @dir(images))
{
while ($file = $dir->read())
{
if(preg_match("/" . $products_image_no_extension . "/i", $file) == 1)
{
if ($products_image_no_extension . str_replace($products_image_no_extension, '', $file) == $file)
{
$left = str_replace($products_image_no_extension, '', $file);
rename("images/".$file,"images/".$new_name_no_extension.$left);
}
else
{
}
}
}
}
$products_res_cf->MoveNext();
}
?>